- How TO — Contact Form
- Example
- Example
- How to create a simple HTML contact form
- Contact us
- The CSS styles to use with the HTML form above
- The PHP Code which captures and Emails your website form
- How to Create a Contact Form in HTML and CSS
- Creating a Contact Us Form in HTML
- Name Text Box
- Email Text Box
- Message Text Box
- Submit Button
- Form Container
- Bonus: Styling a Contact Form Using CSS
- About
- Recent Posts
How TO — Contact Form
Use a element to process the input. You can learn more about this in our PHP tutorial. Then add inputs (with a matching label) for each field:
Example
Step 2) Add CSS:
Example
/* Style inputs with type=»text», select elements and textareas */
input[type=text], select, textarea width: 100%; /* Full width */
padding: 12px; /* Some padding */
border: 1px solid #ccc; /* Gray border */
border-radius: 4px; /* Rounded borders */
box-sizing: border-box; /* Make sure that padding and width stays in place */
margin-top: 6px; /* Add a top margin */
margin-bottom: 16px; /* Bottom margin */
resize: vertical /* Allow the user to vertically resize the textarea (not horizontally) */
>
/* Style the submit button with a specific background color etc */
input[type=submit] background-color: #04AA6D;
color: white;
padding: 12px 20px;
border: none;
border-radius: 4px;
cursor: pointer;
>
/* When moving the mouse over the submit button, add a darker green color */
input[type=submit]:hover background-color: #45a049;
>
/* Add a background color and some padding around the form */
.container border-radius: 5px;
background-color: #f2f2f2;
padding: 20px;
>
Tip: Go to our HTML Form Tutorial to learn more about HTML Forms.
Tip: Go to our CSS Form Tutorial to learn more about how to style form elements.
Ever heard about W3Schools Spaces? Here you can create your website from scratch or use a template, and host it for free.
How to create a simple HTML contact form
You can copy and paste this directly into your HTML page, or use it as a basis for your contact us page.
Contact us