I do not understand step 14. (Cafe Menu)

For step 14 of basic CSS, I have my type selectors, but how would I center h1, h2 and p all at the same time? This puzzles me. Here is my code:

<style>
      h1 selector1{ property: value; 
        text-align: center;
      }
      h2 selector2{ property: value;
        text-align: center;
      }
      p selector3{ property: value;
        text-align: center;
      }
    </style>

Maybe my way of going about it is wrong, I was trying to figure out a way to try to use only 1 selector to align all 3. I don’t see a way how. So instead, I used each selector, as selector 1, 2, and 3. Any advice here?

Link to the challenge: Learn Basic CSS by Building a Cafe Menu: Step 14 | freeCodeCamp.org

1 Like

you shouldn’t be adding the words selector1 in your code, that is an example showing you the syntax

you can give the same css propertyes to multiple selectors, you can write them separated by commas, like it is showing here with the made-up selectors selector1 and selector2

selector1, selector2 {
  property: value;
}

I think my issue is using one of the type-selector(s) to align them all at the same time. Although, what I do notice with the closing tag of the style element, whenever I put a comma, all 3 of of text(s) on the webpage (to the preview) center down. So, I’m close to it.

You need to write all the selectors on the same line separated by commas

What’s your code now?

So, I just did a quick edit from your advice. This is my code all on the same line.

Here’s my code:


<style>
      h1, {text-align: center;} h2, {text-align: center;} p, {text-align: center;}
    </style>
2 Likes

You are close. Reference the first reply from @ilenia and use that format. You should only be adding the properties and values once in total for all three elements.

3 Likes

Listen, I got it! It was just a matter of deleting 2 of my selectors and grouping my elements onto 1 selector.

1 Like

What does your code look like now?

If you have a question about a specific challenge as it relates to your written code for that challenge, just click the Ask for Help button located on the challenge. It will create a new topic with all code you have written and include a link to the challenge also. You will still be able to ask any questions in the post before submitting it to the forum.

Thank you.

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