Good form styles make forms easier to fill in.
Tips
- Make inputs full width:
width: 100%; box-sizing: border-box; - Add
paddingand a softborderwithborder-radius - Show focus clearly with
:focusor:focus-visible - Target input types with attribute selectors:
input[type="email"] - Use
:invalidto highlight wrong values - Inputs do not inherit fonts by default — add
font: inherit;
Example
Example — Styled contact form
HTML
<style>
form { max-width: 340px; font-family: Arial, sans-serif; }
label { display: block; margin: 10px 0 4px; font-weight: bold; }
input, textarea { width: 100%; box-sizing: border-box; padding: 10px; border: 1px solid #bbb; border-radius: 6px; font: inherit; }
input:focus, textarea:focus { outline: none; border-color: #4a90e2; box-shadow: 0 0 0 3px rgba(74,144,226,.3); }
input:invalid:not(:placeholder-shown) { border-color: crimson; }
button { margin-top: 12px; width: 100%; padding: 10px; background: #1f386b; color: white; border: none; border-radius: 6px; cursor: pointer; }
button:hover { background: #2d4f94; }
</style>
<form>
<label for="n">Name</label>
<input id="n" placeholder="Your name">
<label for="e">Email</label>
<input id="e" type="email" placeholder="you@example.com">
<label for="m">Message</label>
<textarea id="m" rows="3"></textarea>
<button type="button">Send</button>
</form>