Learn Basic CSS by Building a Cafe Menu

Hello,

I’m not stuck on an issue, I’ve actually just (finally) figured out step 11…

Step 11

You can add style to an element by specifying it in the style element and setting a property for it like this:

element {
 property: value;
}

Center your h1 element by setting its text-align property to the value center.

However,

my question relates to the solution.
I always believed any element such as h1 etc had to be enclosed with <> and also opened and closed. This code passed once I removed the brackets, can someone explain why this is/why you wouldn’t use them in this scenario?

I want to understand why rather than just accept it so I fully understand for next time.

(I apologise if this gives away the solution, please remove if it goes against guidelines)

To reply to my own question, I think the following step actually helped explain but please clarify.

Is it because you are within the style element already and only instructing the h1 and any other elements you may want with a certain style? If that makes sense.
Thanks

Welcome to our community!

If you want to style your html element, such as a text between h1 tags: <h1>Text</h1> you can do it in two ways. The first is to add the <style></style> element to your HTML code and put the CSS rule within. The other is to write the CSS rule directly into a CSS file (styles.css). So, in the step mentioned in the post, you should apply the first solution.

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