CSS: class selectors

By Xah Lee. Date: . Last updated: .

match class name

.val

Any element with attribute class value of val

Same as

[class~="val"]

.navback-6966 {
 border: solid 1px grey;
}

match multiple class name

.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