Home > OS >  how can i nest <input> tag within <label> tag in html?
how can i nest <input> tag within <label> tag in html?

Time:06-15

est an input element within each label. Be sure to add each input after the label text, and include a space after the colon.

    <form>
             <label>Enter Your First Name:</label>
             
    </form>

CodePudding user response:

It's perfectly valid HTML to nest an input inside a label.

<label>First Name:
  <input type="text" name="firstname">
</label>

You don't need the for and id attributes in these cases as they are implied by the markup.

CodePudding user response:

Here is the Way

<label for="firstName"></label>
<input type="text" id="firstName" placeholder="Enter Your Name">

Always Remember The Value ID of the Input element and the Value of For in Label element should be same.

  •  Tags:  
  • html
  • Related