Hi!
Can you please share your code and a link to the lesson? It is hard to help without seeing your code and a link to the lesson makes it easier to check your code. If I can see your code I can know the best way to explain selectors to you.
Also in future, use the ‘ask for help’ button. It will provide your formatted code, a lesson link and browser information. Which gives all the info needed to answer your question quickly.
A selector tells CSS what element to affect, ie. div, p, and body or in the case of classes = .example and for id’s = #example.
In the case of selecting html elements, CSS will affect ALL elements that match that type. So using classes and id’s helps specify which element you want.
This will turn all <p> elements red. The selector is the p, the property is color and the attribute is red.
So, if you want to create a h1 selector with the property of text-align and attribute of centre you would follow the same format as with the p element example. Does this make sense?
I’ve edited your code for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.
You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.
Html elements must have correct opening and closing tags. Content can go in-between these tags. Attributes can go inside html tags, but a selector is not an attribute.
This is correct.
<p>This is a paragraph</p>
This is incorrect.
<p this is a paragraph <p
The selector code for the h1 element to align in the center is correct and the closing tag of your style element is correct.
But the opening style tag is missing its closing bracket. There also is an extra bracket after the last curly bracket that should not be there.