I want to assign one class, like "centered" to some, all, or each of my text elements, like <h1 class="centered">, <h2 class="centered">, <h3 class="centered">, <p class="centered">
.
I need to target only specific elements because I may want some different rules for block elements like <div class="centered">
.
If you think this question is easy to get an answer for, try Googling it. No matter how I phrase the question, Google thinks I'm asking "how to assign multiple classes to one element". I know how to give an element multiple classes, so, no, that's not what I want.
What I've tried:
h1, h2, h3, p .centered{
text-align:center;
}
That can't be right. That's just saying the centered class shares the same css rules with h1, h2, and h3.
Right now I'm reduced to this method, which seems inelegant, and probably amateur:
h1.centered{
text-align:center;
}
h2.centered{
text-align:center;
}
h3.centered{
text-align:center;
}
...etc.
centered
CSS, and then create separate rules modifying the general CSS for just the elements you want to be different. By the way, all the elements you mentioned are block elements.