Skip to content

CSS Selectors

CSS Class

About

The .class selector selects all elements with the given class name.

Button with classes

The selector .btn matches all elements with the class btn (and optionally other classes). The last button does not have the class btn and is not matched.

  • Change the selector to match elements with the btn-primary class

Button with multiple classes

You can combine multiple classes in a selector by chaining them together. The selector .foo.bar matches all elements with both, the foo and bar class.

  • Change the selector to match elements with both classes, btn and btn-primary