Basic CSS - Use Attribute Selectors to Style Elements

I did this but I’ve no idea why isn’t this selecting all the checkboxes.

<link href="" rel="stylesheet" type="text/css">
  .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;
  input[type = 'checkbox']{
    margin-top: 10px; 
    margin-bottom: 15px;

<h2 class="red-text">CatPhotoApp</h2>
  <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="" alt="A cute orange cat lying on its back."></a>
  <div class="silver-background">
    <p>Things cats love:</p>
      <li>cat nip</li>
      <li>laser pointers</li>
    <p>Top 3 things cats hate:</p>
      <li>flea treatment</li>
      <li>other cats</li>
  <form action="/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>

Link to the challenge : Basic CSS - Use Attribute Selectors to Style Elements


Try changing this line:

 input[type = 'checkbox']



I think this may be down to the way the tests are being run, as I tried the syntax with spaces on and it worked fine.

Hope this solves your probem :slight_smile:


Man, this isn’t fair :frowning_face:
what’s the difference in between the space and that was proper indentation :frowning_face:

1 Like

It might just be a styling choice. All of the examples that I looked at were without spaces

1 Like

Thank you guys for your references!!

This code passes as well. Hope this can help other people

    margin: 10px 0px 15px 0px;

I guess now they’ve changed their tests :joy::joy::joy:

1 Like

I have done exactly this but it’s not working… Am I doing something wrong here?

Could you tell me where exactly are you inserting this code?

I have inserted it as the last class within the element.

Why is it not working?

I am getting this error:

If you shared your code possibly someone would spot your problem.

Based on your errors it would appear that your selector is correct but you have not applied the margin styles correctly.

You should not need to create any classes for elements. Possibly that is the source of your error.

1 Like

No the error was something else. I’ve already found it and fixed it. It was spotted by some users on this thread.

Thanks for your reply.

@MrVega could you please share your corrected solution with us

Thanks. it worked perfectly.

yes it works. thanks