Nest text in a label

Tell us what’s happening:
Describe your issue in detail here.

I am having a hard time understanding how to nest an input’s text within a label and associating it with a for attribute. I’m tryin to do this with my “loving” id. I just need a better explanation.

  **Your code so far**
       <fieldset>
         <legend>Is your cat an indoor or outdoor cat?</legend>
         <label><input id="indoor" type="radio" name="indoor-outdoor" value="indoor"> Indoor</label>
         <label><input id="outdoor" type="radio" name="indoor-outdoor" value="outdoor"> Outdoor</label>
       </fieldset>
       <fieldset>

         *<legend>What's your cat's personality?</legend>*
*          <input id="loving" type="checkbox"> Loving*
*        </fieldset>*
      
  **Your browser information:**

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36

Challenge: Learn HTML by Building a Cat Photo App - Step 55

Link to the challenge:

1 Like

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').

this is an input element: <input>
To associate it with a label you add an id to it: id="someID"

Then you create a label element, you put some text inside it, and use the for attribute with a value equal to the id of the label: <label for="someID">some text</label>, if you do this, you can put the input and the label in different places in the page, and they are still going to be linked, meaning that when you click the label, the input is also going to be selected

Thanks for your help. :slight_smile: