Selectors to Style Elements

Hello, I don’t understand this one, can anyone help explain it.

[type='checkbox'] {
  margin: 10px 0px 15px 0px;   ( This is what I have and not sure were to put it) 
}

<link href="https://fonts.googleapis.com/css?family=Lobster" rel="stylesheet" type="text/css">
<style>
.red-text {
  color: red;
}

h2 {
  font-family: Lobster, monospace;
}

p {
  font-size: 16px;
  font-family: monospace;
}

.thick-green-border {
  border-color: green;
  border-width: 10px;
  border-style: solid;
  border-radius: 50%;
}

.smaller-image {
  width: 100px;
}

.silver-background {
  background-color: silver;
}
</style>

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

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

<div class="silver-background">
  <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>
</div>

<form action="https://freecatphotoapp.com/submit-cat-photo" id="cat-photo-form">
  <label><input type="radio" name="indoor-outdoor" checked> Indoor</label>
  <label><input type="radio" name="indoor-outdoor"> Outdoor</label><br>
  <label><input type="checkbox" name="personality" checked> Loving</label>
  <label><input type="checkbox" name="personality"> Lazy</label>
  <label><input type="checkbox" name="personality"> 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 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36 Edg/100.0.1185.44

Challenge: Use Attribute Selectors to Style Elements

Link to the challenge:

every think between the opening < and the closing one > is attribute , this include classes id and in your case type. note you can use name as well

so looking at the challenge code.

<input type="checkbox" name="personality"> 

it asking you to change checkbox input but not radio , text , or submit

knowing that between anything in<input .... > is attribute,

input [attribute="value"] {
}

you can select the attribute type with value checkbox to change the css style

which resulted in this

[type='checkbox'] {
 
}

Okay so when I am typing it out it would be like this.

[type=‘checkboxes’] {
margin: 20px 0px 20px 0px;
}
After this I am thinking that I would put this between the: [type=‘checkboxes’] {
margin: 20px 0px 20px 0px;
}

After this, if I am right, I am not sure where to go.
I believe in the where the checkboxes are but not sure on what I should type in. I am trying, I think: input type=“checkboxes” “margin”
But this does not seem to work.

you are overthinking it a bit.

when i said

every think between the opening < and the closing one > is attribute , this include classes id and in your case type . note you can use name as well

it means that this works as class as well

[type='checkbox'] {
 
}

so if you copy your first code which is

[type='checkbox'] {
  margin: 10px 0px 15px 0px;   // This is what I have and not sure were to put it
}

and paste it in <style></style>
it will pass the challenge because it’s acting like any selector would but with different Specificity

After this I am thinking that I would put this between the: [type=‘checkboxes’] {
margin: 20px 0px 20px 0px;
}

if i am understanding this correctly you want it to be more specific to input tags to be something like

h1 .class {
background-color: red;
}

yes you should to make it more readible so it will be like

tag [attribute="value"] {
background: red;
}

so looking at your code so far you want to add tag before attribute

input [type='checkbox'] {
}

I believe you were right about over thinking it. Thank you for explaining it more because I get it. I am making sure I grasp what I am doing in full.

I wish you well!

1 Like

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