Isn’t the first one we learned “tag name selector”?


#1

Isn’t the first one we learned “tag name selector”?

Or is that there another official name for it?


What is a CSS selector?
#2

Selector is another term to describe an element, which is made up of tags and content/and or attributes.

<p>        => tag      (OPENTAG)
</p>       => tag      (ENDTAG)
<p></p>    => element  (selector)

id and class are special attribute selectors tied to specificity.

p {}       => node type selector      =>  0 0 0 1
.class {}  => class selector          =>  0 0 1 0
#id {}     => id selector             =>  0 1 0 0
style=""   => inline style selector   =>  1 0 0 0

The only higher specificity is !important whch is a clear signal there is an inline style somewhere that maybe shouldn’t be.

Any attribute can be specified in a selector, indicated by [attr].

<span lang="fr"></span>

span {}              => node type selector
span[lang] {}        => node with attribute selector
span[lang="fr"] {}   => node with attribute with value selector