Publish in HTML Tutorial el 24/05/2025 16:11
The <label> element is a crucial HTML tag that improves form accessibility and usability. It creates a caption for form elements like inputs, textareas, selects, etc. When properly associated with a form control, clicking the label focuses or activates the control, making the interface more user-friendly.
Key features of <label>:
Here's the basic structure of a label element:
The most common use case - associating a label with a text input.
Alternative method where the input is nested inside the label (no "for" attribute needed).
Using labels with radio buttons creates a more accessible radio group.
This example shows how to use JavaScript to focus an input when its label is clicked.
This example demonstrates using JavaScript to toggle visibility of an input when clicking its label.
Labels are essential for accessibility:
The <style> HTML element contains style information for a document, or part of a document. ...
The <strong> element is used to indicate that its content has strong importance, seriousnes...
The <span> element is an inline container used to mark up a part of a text or document. Unl...
The <source> element is used to specify multiple media resources for media elements like &l...
The <small> element is used to represent side-comments and small print, typically for discl...
HTML <section> Element: The Complete Guide The <section> element is a semantic HTML ...