Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lära Labeling Form Inputs | Section
Practice
Projects
Quizzes & Challenges
Quizzes
Challenges
/
HTML Basics for Absolute Beginners (Sliced) - 1768407373666

bookLabeling Form Inputs

Labels (<label>) are essential for linking text labels with form input elements, enhancing accessibility and user-friendliness. It's crucial that the for attribute of the <label> tag matches the id attribute of the associated input element.
Example:

<label for="username">Username:</label>
<input type="text" id="username" />

In the example above:

  • When you click the Username: label, it will automatically focus on the corresponding input field;
  • The label and input are linked together using the for and id attributes, respectively;
  • Both for and id attributes have the same value (username).

Let's make filling in the form easier by adding labels to the inputs from the previous example.

index.html

index.html

copy

1. What attribute of the <label> tag is used to associate it with a specific <input> element in a form?

2. What attribute is missing for the input element that needs to be associated with the label element?

question mark

What attribute of the <label> tag is used to associate it with a specific <input> element in a form?

Select the correct answer

question mark

What attribute is missing for the input element that needs to be associated with the label element?

Select the correct answer

Var allt tydligt?

Hur kan vi förbättra det?

Tack för dina kommentarer!

Avsnitt 1. Kapitel 28

Fråga AI

expand

Fråga AI

ChatGPT

Fråga vad du vill eller prova någon av de föreslagna frågorna för att starta vårt samtal

bookLabeling Form Inputs

Svep för att visa menyn

Labels (<label>) are essential for linking text labels with form input elements, enhancing accessibility and user-friendliness. It's crucial that the for attribute of the <label> tag matches the id attribute of the associated input element.
Example:

<label for="username">Username:</label>
<input type="text" id="username" />

In the example above:

  • When you click the Username: label, it will automatically focus on the corresponding input field;
  • The label and input are linked together using the for and id attributes, respectively;
  • Both for and id attributes have the same value (username).

Let's make filling in the form easier by adding labels to the inputs from the previous example.

index.html

index.html

copy

1. What attribute of the <label> tag is used to associate it with a specific <input> element in a form?

2. What attribute is missing for the input element that needs to be associated with the label element?

question mark

What attribute of the <label> tag is used to associate it with a specific <input> element in a form?

Select the correct answer

question mark

What attribute is missing for the input element that needs to be associated with the label element?

Select the correct answer

Var allt tydligt?

Hur kan vi förbättra det?

Tack för dina kommentarer!

Avsnitt 1. Kapitel 28
some-alt