Feni
February 3, 2023, 10:05am
1
Hi Err’body
I’m stuck.
I am required to add a “Checked” attribute to an “Input” element in order for the radio button to be selected by default.
Below is how my code looks.
<fieldset>
<legend>Is your cat an indoor or outdoor cat?</legend>
<label><input id="indoor" type="radio" name="indoor-outdoor" value="indoor" checked="default">Indoor</label>
<label><input id="outdoor" type="radio" name="indoor-outdoor" value="outdoor" checked="default">Outdoor</label>
</fieldset>
Thank you in advance guys.
hbar1st
February 3, 2023, 10:32am
4
I’ve edited your code 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 (').
hbar1st
February 3, 2023, 10:33am
5
Feni:
checked="default"
The attribute checked is special and does not need a value as it means that the button is in a checked state.
Also, please post a link to the challenge.
Feni
February 3, 2023, 11:22am
6
Oh, please excuse me. Now I know. Thank you so much
Here’s the link:
Learn HTML by Building a Cat Photo App: Step 61 | freeCodeCamp.org
Also, I get what you mean about dropping the value as it’s not required. But how would I code it in. Because I tried and it still results in an error.
I did it this way:
`<label><input id="indoor" type="radio" name="indoor-outdoor" value="indoor" checked> Indoor</label>`
It won’t budge.
hbar1st
February 3, 2023, 11:28am
7
Read this instruction again
Make the first radio button and the first checkbox selected by default.
I will rewrite it to make it clearer for you.
Make [both] the first radio button
and the first checkbox
selected by default.