20 min read
Styling Forms
Labels on their own lines, full-width fields, clear focus outlines, tidy fieldsets and friendly buttons.
A Friendly Form
What the browser shows
Try it: Click into a field to see the focus outline. Remove display: block from label and see the labels jump beside the fields.
| Form styling explained | |
|---|---|
Checkboxes and Radio Buttons
Choices side by sideCSS
.choice { display: inline-block; font-weight: normal; margin-right: 16px;}On the example site, each checkbox and radio button is wrapped in a label with class="choice", so the options sit in a row instead of one per line.
Practice
Which rule puts each label on its own line above its field?
More lessons in CSS · Next: Flexbox: a Row of Cards · Previous: Styling Tables
