How can I add 'checked' w/o making any changes to the input label as required? Editing the label to add 'checked' looks like a must to me. Help pls!

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

  **Your code so far**

<h2>CatPhotoApp</h2>
<main>
<p>Click here to view more <a href="#">cat photos</a>.</p>

<a href="#"><img src="https://cdn.freecodecamp.org/curriculum/cat-photo-app/relaxing-cat.jpg" alt="A cute orange cat lying on its back."></a>

<p>Things cats love:</p>
<ul>
  <li>cat nip</li>
  <li>laser pointers</li>
  <li>lasagna</li>
</ul>
<p>Top 3 things cats hate:</p>
<ol>
  <li>flea treatment</li>
  <li>thunder</li>
  <li>other cats</li>
</ol>
<form action="https://www.freecatphotoapp.com/submit-cat-photo">
  <label for="indoor"><input id="indoor" type="radio" name="indoor-outdoor" value="indoor" checked> Indoor</label>
  <label for="outdoor"><input id="outdoor" type="radio" name="indoor-outdoor" value="outdoor"> Outdoor</label><br>
  <label for="loving"><input id="loving" type="checkbox" name="personality" value="loving" checked> Loving</label>
  <label for="lazy"><input id="lazy" type="checkbox" name="personality" value="lazy"> Lazy</label>
  <label for="energetic"><input id="energetic" type="checkbox" name="personality" value="energetic"> Energetic</label><br>
  <input type="text" placeholder="cat photo URL" required>
  <button type="submit">Submit</button>
</form>
</main>
  **Your browser information:**

User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36

Challenge: Check Radio Buttons and Checkboxes by Default

Link to the challenge:

Your code is passing for me.

How can I add ‘checked’ w/o making any changes to the input label as required?

You can’t. That is fundamentally what this lesson is about. Whey do you think you aren’t allowed to do that?

Editing the label to add ‘checked’ looks like a must to me.

I don’t understand why you need to do anything to the label.

hi Kevin,
The code isn’t passing for me despite adding ‘checked’ within the input label.

I’ve copied and pasted one of the reasons for failing below:

You should not change the inner text of the Indoor label.

But the issue is that i cannot add checked w/o having to make changes to the indoor label for example.

I’m going to agree with @kevinSmith here, I just copy/pasted your code above into the challenge and it passed for me. Can you try copy/paste too and see what happens?

hi @bbsmooth i’ve just copied and pasted the code and i’m still getting the same reasons for failing:

// running tests

You should not change the inner text of the Indoor label.

You should not change the inner text of theLoving label.

// tests completed

I’ve watched the help video too and i’ve been doing the same thing from the start, adding ‘checked’ in the input element

I don’t know what to tell you? Two of us have confirmed that the original HTML you posted here is correct. The main point of this challenge is to understand what the checked attribute does and I think you have demonstrated that you know how to use it. I would just write this off as some weird aberration and move on to the next challenge.

I also copied your code and it worked. Perhaps clearing your cache/cookies/etc would help?

2 Likes

Thanks @dallasviars this fixed it!

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.