Register to Better Coder! It's free.
Enjoy the premium features and succeed at every job interview.
What is a <label> tag?
Experience Level: Junior
<label> tag is used to render a label of an input element.
Imagine you have a form with two text fields - first name and last name. Each text field is be defined by
<input type="text"/ > tag. How will the user know what to enter into each text field when it isn't labeled?
The solution is to use the
You could obviously use
<label> is better for usability, because the screen readers can understand that
<label> is labeling some field whereas
<span> is understood to be just some text.
Related HTML job interview questions
What is a <ul> tag?HTML Junior
What is a <input> tag?HTML Junior
What is a <p> tag?HTML Junior
What is a <span> tag?HTML Junior
What is a <div> tag?HTML Junior