What is an h2 selector? (Basic CSS)

So, I know what an h1 type selector is, and I’ve aligned my code correctly using the h1 type selector for p and h2 elements, but it tells me instead I need to use an h2 selector.

What is an h2 selector exactly?

Here is my code


  <style>
      h1 {
        text-align: center;
      }
    </style>
  </head>
  <body>
    <header>
      <h1>CAMPER CAFE</h1>
      <p>Est. 2020</p> <style> p {text-align: center;}</style>
    </header>
    <main>
      <section>
        <h2>Coffee</h2> <style> h2 {text-align: center;}</style>
      </section>
    </main>
  </body>
<html>

Here’s the link to the challenge.

Learn Basic CSS by Building a Cafe Menu: Step 13 | freeCodeCamp.org

h1 {
  text-align: center;
}

In plain English this says "give all h1 elements the text-align style center".

You need to add some more CSS to "give all h2 elements the text-align style center", and some more to "give all p elements the text-align style center".

The “selector” is the part of the code that targets which elements to apply styles to. In the example h1 is a selector.

1 Like

Ah, I didn’t have a good look at your code! It looks like you’ve written the CSS in multiple style tags.

You should keep all of the CSS inside the single style tag already provided for you. For example, if you were to add some CSS for a tags you could write it this way:

    <style>
      h1 {
        text-align: center;
      }

      a {
        text-align: center;
      }
    </style>
1 Like

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