How can I replace the three selectors? This is what I'm doing

{ selector h1, h2, p, text-align: center; }
1 Like

the word selector is not a ‘selector’
so you should delete that
the words h1,h2,p are the selectors.

The syntax for writing a selector is like below:

name-of-selectors {
property: value;

So you have to place the h1,h2,p in the name-of-selectors area
and the text-align: center; in the property: value; area


You can replace the three selectors in your code with a class or a group of classes, like this:

.center-align {
  text-align: center;

And then you can apply this class to the relevant elements, like this:

<h1 class="center-align">...</h1>
<h2 class="center-align">...</h2>
<p class="center-align">...</p>

Or, if you want to group multiple classes, you can use the class syntax as follows:

.header, .paragraph {
  text-align: center;

And then you can apply these classes to the relevant elements:

<h1 class="header">...</h1>
<h2 class="header">...</h2>
<p class="paragraph">...</p>

Now it makes sense, now looks so easy!!!
It’s working, thank you so much.


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