Junior
In which cases should a link, button, or label element be used?
sobes.tech AI
Answer from AI
- Link (
<a>): For navigating to another webpage or within the current page (anchors). Semantically means navigation. - Button (
<button>): For performing an action on the current page (submitting a form, showing/hiding an element, calling a JavaScript function, etc.). Semantically means an action. labelelement: For associating a text label with a form element (input,select,textarea). Improves accessibility and usability by allowing clicking on the label to focus on the associated field.
<!-- Example of a link -->
<a href="/about">About us</a>
<!-- Example of a button -->
<button type="button">Send</button>
<!-- Example of label -->
<label for="username">Username:</label>
<input type="text" id="username">