Write an HTML program to create a contact form
Description: Create a contact form with name, email, subject and message fields, and a Send button.
Hint:
- Use
textareafor the long message. - Mark the important fields with
required.
HTML contact form
<form action="contact.php" method="post">
<p><label for="cname">Name:</label><br>
<input type="text" id="cname" name="name" required></p>
<p><label for="cemail">Email:</label><br>
<input type="email" id="cemail" name="email" required></p>
<p><label for="subject">Subject:</label><br>
<input type="text" id="subject" name="subject"></p>
<p><label for="message">Message:</label><br>
<textarea id="message" name="message" rows="5" cols="40" required></textarea></p>
<button type="submit">Send</button>
</form>
Output in the browser:
Output in the browser
How it works
<br>puts the field below its label.rowsandcolsset the size of the textarea.- The server file
contact.phpreads the values and sends the email. A form alone cannot send an email.
Also see our HTML contact form template.
Learn more about the similar topics:
| Tutorials |
|---|
| No Content Found. |
| Exercises & Assignments |
|---|
| No Content Found. |
| Interview Questions & Answers |
|---|
| No Content Found. |