CSS: Selector Syntax
Here's complete list of CSS Selectors syntax. For a tutorial, see CSS: Selector Tutorial
Match by Tag Name
*
-
(This is called universal selector)
Match any element. [see HTML Tags Complete List]
/* make everything red */ * {color:red;}
tag
-
(This is called type selector)
Match any element with tag name tag.
/* make all paragraphs red */ p {color:red;}
Match by Attribute
Match by Checking Parent
Match by Checking Children
tag:empty
-
Match tag that has no children.
🛑 WARNING: It must not have any inner-text, not even space or newline.
Match by Checking Sibling Relations
Negation
tag:not(expr)
-
Match element with tag name tag if it does not match selector expr.
/* match p, only if it is not class x */ p:not([class="x"]) { color:red; }