Use CSS Selectors to Style Elements – freeCodeCamp

Delete your h2 element’s style attribute, and instead create a CSS style block. Add the necessary CSS to turn all h2 elements blue.


<style>
  h2 {
    color:blue;
  }
</style>

<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>

  <div>
    <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">
    <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>

Next task: Set the Font Family of an Element

Add the following code for style tag inside p element.

font-family: monospace;

Next task: Import a Google Font

Import the Lobster font to your web page. Then, use an element selector to set Lobster as the font-family for your h2 element.

Add the following code (inside black box) after the p selector inside style tag. Don’t forget to copy paste this code before opening of style tag: <link href=”https://fonts.googleapis.com/css?family=Lobster” rel=”stylesheet” type=”text/css”>

h2{
     font-family: Lobster;
  }
0 0 votes
Article Rating
Was this article helpful?
YesNo
Subscribe
Notify of
guest

0 Comments
Most Voted
Newest Oldest
Inline Feedbacks
View all comments
Scroll to Top