Forms & Inputs

HTML <label> Tag

The <label> tag defines a label for several elements:

Definition and Usage

The <label> tag defines a label for several elements:

Standard Syntax:<label>...</label>

Interactive ExampleRunnable

HTML <label> Example

html
Try it Yourself
Live code demonstration for the <label> tag. Click "Try it Yourself" to edit and experiment in real time.
<div style="font-family: system-ui, sans-serif; padding: 16px; background: #ffffff; border-radius: 8px; border: 1px solid #e2e8f0; color: #0f172a;">
<form action="/action_page.php">

      <input type="radio" id="html" name="fav_language" value="HTML">
  
    <label for="html">HTML</label><br>
  <input type="radio" id="css" name="fav_language" 
    value="CSS">
  <label for="css">CSS</label><br>
  <input type="radio" 
    id="javascript" name="fav_language" value="JavaScript">
  <label for="javascript">JavaScript</label><br><br>
  
    <input type="submit" value="Submit">
</form>
</div>

Attributes for <label>

2 Supported Attributes
AttributeValuesDefaultDescription
forelement_idnoneSpecifies the id of the form element the label should be bound to
formform_idnoneSpecifies which form the label belongs to
Global Attributes

The <label> tag also supports the standard global attributes in HTML, including class, id, style, title, hidden, and data-*.

HTML Global Attributes Reference →
Event Attributes

The <label> tag supports event attributes in HTML, such as onclick, onmouseover, onfocus, and more.

HTML Event Attributes Reference →

Browser Compatibility

ChromeEdgeFirefoxSafariOpera

More Tags in Forms & Inputs

View All 123Tags →