Import a Google Font Error- Use an h2 CSS selector to change the font

Import a Google Font Error- Use an h2 CSS selector to change the font
0.0 0

#1

Tell us what’s happening:
I can set the selector within the style to h2 and change the font to lobster after I’ve imported the font, but I get an error saying I need to “Use an h2 CSS selector to change the font.”
Does it want me to create a class and set the font within the h2 element (like below)? Or does it want me to use h2 as the selector in the <style block (which I’ve also tried and gotten the same error)?

I can’t tell whether I’m doing something wrong or there is some sort of glitch. I can see the text font change and I’ve treid using h2 as a selector within the style, as well as the element itself and I get the same error.

Your code so far


<link href="https://fonts.googleapis.com/css?family=Lobster" rel="stylesheet" type="text/css">
<style>
  .red-text {
    color: red;
  }
  .lobster {
    font-family: Lobster, "Open Sans";
     }
  p {
    font-size: 16px;
    font-family: monospace;
  }
</style>

<h2 class="lobster">CatPhotoApp</h2>
<main>
  <p class="red-text">Click here to view more <a href="#">cat photos</a>.</p>
  
  <a href="#"><img src="https://bit.ly/fcc-relaxing-cat" 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="/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>

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/responsive-web-design/basic-css/import-a-google-font


#2

You created a class called lobster which is working, but isn’t quite what the challenge asked for. Instead of creating a class like you did for red-text, you should create an element selector like you did for p elements.


#3

Your code so far


<link href="https://fonts.googleapis.com/css?family=Lobster" rel="stylesheet" type="text/css">
<style>
  .red-text {
    color: red;
  }
  h2 {
    font-family: Lobster, "Open Sans";
     }
  p {
    font-size: 16px;
    font-family: monospace;
  }
</style>

<h2>CatPhotoApp</h2>
<main>
  <p class="red-text">Click here to view more <a href="#">cat photos</a>.</p>
  
  <a href="#"><img src="https://bit.ly/fcc-relaxing-cat" 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="/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>

Like this? I’m still getting the same error


#4

I think there might be a problem with that test. If there isn’t one already, you can crate a GitHub Issue and then just move to the next challenge using the curriculum map.


#6

There is no problem with the Test, All you need to do is add the Class red-text to your h2 element or the h2 tag…

<h2 class="red-text">CatPhotoApp</h2>

This makes the h2 element to be Displayed in Lobster font and in Red-Text


#7

add the following
h2 {
font-family: Lobster;
}


#8

Had the same issue with this challenge using Firefox (correct answer, but test wasn’t happy). No problem in Chrome.

A similar thing happened later in a CSS challenge and decided to use Chrome in fcc :slight_smile:


#9

I am getting errors on the same challenge. Here is my style code. It is saying that my h2 element is not using Lobster and my p element is not using monospace. How do I make this happen? Also, all of my style commands are showing at the top of my webpage, rather than remaining as style elements.

.red-text { color: red; } h2 { font-family: Lobster; } p { font-size: 16px; font-family: monospace; }