So if I have the code:
<h1>Here is some filler code</h1>
<h1>Here is some more filler code</h1>
Is there some way I can use CSS to make every element have a class?
For example, if I have a class called "text":
.text{
color: white;
}
can I use a CSS declaration for every h1 to be in the "text" class?
I couldnt find any declarations using CSS like "class:", so I was just wondering.
2
Answers
If you want to add a class you will have to manually add it
But you can target the
h1
with css without using a class. Just by using the tag nameso in your css
Read more about CSS at https://developer.mozilla.org/en-US/docs/Web/CSS
Finally, if you need to add a class to the
h1
but cannot modify the actual html, you can add it with javascriptIf you really need to select all h1’s you can use, element selector itself..
Eg: