🏷️Label
Add accessible labels to form inputs in Webstudio.
See MDN: <label>
The Label component creates an HTML <label> element that provides an accessible name for form controls.
Overview
Labels are essential for form accessibility. They tell users what information to enter and allow clicking the label to focus its associated input.
Properties
for
string
ID of the associated form control
id
string
Unique identifier
class
string
CSS class names
Associating Labels with Inputs
Method 1: Using for Attribute
Match the label's for attribute to the input's id:
Label (for: email)
└── "Email Address"
Input (id: email, name: email, type: email)Method 2: Wrapping
Place the form control inside the label:
Benefits of Labels
Accessibility: Screen readers announce the label when the input is focused
Usability: Clicking the label focuses the associated input
Touch targets: Increases the clickable area on mobile devices
Styling Labels
Typography
Font Weight: Slightly bolder than body text
Font Size: Same or slightly smaller than inputs
Color: High contrast for readability
Layout
Position: Above input (most common) or beside it
Spacing: Add margin between label and input
Alignment: Align with input edges
Required Field Indicators
Show required fields with visual indicators:
Form Layout Patterns
Stacked Labels (Most Common)
Inline Labels
Floating Labels
Create floating label effect with CSS positioning:
Position label absolutely over input
On input focus/filled, translate label up
Reduce font size when floating
Checkbox and Radio Labels
For checkboxes and radio buttons, wrap or associate labels:
This makes the entire label clickable.
Best Practices
Always use labels: Every form control needs a label
Be descriptive: Clearly describe expected input
Keep it concise: Short, clear labels work best
Mark required fields: Indicate which fields are required
Don't rely on placeholders: Placeholders disappear, labels don't
Error Messages
Associate error messages with the field:
Accessibility Tips
Use proper label associations
Include required field indicators in label text for screen readers
Group related fields with fieldset and legend
Ensure sufficient color contrast
Related Components
Input - Text input fields
Textarea - Multi-line text input
Checkbox - Checkbox input
RadioButton - Radio button input
Form - Form container
Last updated
Was this helpful?
