@d-donne
Posted
To answer your question on using elements (Tag names) as CSS selectors, there's actually nothing wrong with it if you want elements of that type to have a general styling.
Class Names Have Higher Specificity Than Tag Names.
When you give that element a class name, the CSS styling using the class name will override the Tag name's styling affected by that CSS property.
For instance:
HTML
<p class="text-red" id="text-green">
CSS
p {
background-color: black;
color: white;
}
.text-red {
background-color: yellow;
color: red;
}
#text-green {
color: green;
}
If this paragraph is styled using the CSS, it'll actually show a green text with a yellow background, because IDs are more specific than class names, and class names than Tag names.
Here is an article I found: Importance of CSS Specificity
Marked as helpful