CSS · CSS Tutorial · Lesson 35
CSS Forms
Style inputs, textareas, selects and buttons.
The look of an HTML form can be greatly improved with CSS.
Example
<style>
input[type=text], select, textarea {
width: 100%; padding: 12px; margin: 6px 0 14px;
border: 1px solid #ccc; border-radius: 6px; box-sizing: border-box;
}
input[type=text]:focus { border-color: #04AA6D; outline: none; box-shadow: 0 0 0 3px #c9f2e1; }
input[type=submit] { background: #04AA6D; color: white; padding: 12px 20px; border: none; border-radius: 6px; cursor: pointer; }
input[type=submit]:hover { background: #037a4e; }
</style>
<form>
<label>Name</label><input type="text" placeholder="Your name..">
<label>Country</label><select><option>Australia</option><option>Canada</option></select>
<label>Message</label><textarea rows="3"></textarea>
<input type="submit" value="Submit">
</form>
Tip: Use
box-sizing: border-box so padding does not make full-width inputs overflow their container.Keep reading “CSS Forms”
Sign up to read the full lesson, try every example in the live editor, and take the 5-question quiz.