CSS: class selector (.x)

By Xah Lee. Date: . Last updated: .

match class name

.val

Any element with attribute class value of val

Same as

[class~="val"]

.xx {
 border: solid 1px grey;
}

match multiple class names

.val1.val2.etc

Any element with attribute class value of val1 and val2 and etc

<div class="aa bb"> something </div>
.aa.bb {
border: solid 1px red;
}

match tag name and class name

tag.val

Element tag with attribute class value of val.

Same as

tag[class~="val"]

nav.x6981 {
 border: solid 1px grey;
}

HTML class attribute

CSS, Selectors

Selector types
Simple selectors
Combinators
Selector list
Special selector
Misc