DEV Community

Kunal Agrawal
Kunal Agrawal

Posted on

CSS Selectors.

CSS selectors, these are used to select a particular or group of tags sharing some common thing like class name, id, (siblings), tag name.

Selectors follow specificity (say priority), for example if there is a tag having class = a and id = b. If you're selecting a element with a and b then CSS property given to b are applied.

You can read more about css selectors here.

Basic Selector

Universal Selector

selects all the elements, denoted by *.

Type Selector

This selector selects all elements with same tag name.
tag_name.

Class Selector

This selector selects all elements with class name that is selected.
class_name.

ID Selector

This selector selects element with a id.
many elements can have one id, but use class for this, it's just convention.
id_name.

Top comments (0)