HTML label tag

The HTML label is used for input of the form, with a label tag showing the label text of the input. label text works like a button, as if you clicking on it, you reach inside the input.

The label tag can also be used with “for” attribute and without “for” attribute. Below are some examples, after seeing which you will find out how you can use the label tag.

Html Label Using for attribute

<label  for="age" > Are you 20 years old? </label>
<input  type="checkbox" name="age" id="age" value="yes">

<label  for="feet"> Are you 6 feet tall?</label>
<input  type="radio" name="height" id="feet" value="yes">

<label for="name"> Your Name</label>
<input  type="text" name="name" id="name">

Html Label Without for attribute

<label>Are you 20 years old?
    <input type="checkbox" name="age" value="yes">

 <label>Are you 6 feet tall?
    <input type="radio" name="height" value="yes">

 <label>Your Name 
    <input type="text" name="name">

Browser Support

  • Google Chrome
  • Internet Explorer
  • Opera
  • Mozilla Firefox
  • Safari
Live Demo Of HTML Label Tag

Frequently Asked Questions

We have answers to some questions, which people often search on Google. Let’s know which are those questions and what are their answers.

Why label is used in HTML?

A label tag is used to display the input text.

How do I create a label in HTML?

With <label> tag you can add label.

How do I link CSS to HTML?

There are 3 types of CSS external, internal, and inline. If you want to install internal CSS, you can put it in the <style> tag inside the <head> tag.

If you want to use external CSS, then for that you have to link CSS under <head> tag.

For example (<link rel = “stylesheet” href = “mystyle.css”>).

What is a placeholder in HTML?

The placeholder attribute is used to display the text inside the input, or to indicate to the user what value to put inside the input.

What is div in HTML?

In simple language, div is a box, inside which you can create a large model by adding your elements.

Note: All the examples shown in this article, we have tested before, you can use these examples without any difficulty.

Related: Basic 8 Syntax Of CSS Hover Effect