DEV Community

Discussion on: What are selectors in CSS? Explain breafly.

Collapse
 
kerldev profile image
Kyle Jones

CSS takes the structural elements of a web page (defined in your HTML) and applies styling to them.

To do this, CSS uses selectors and effects.

An effect is a visual description of the element - it might be the colour of something, the position of something, it's size etc.

The selector is how you determine which element you're describing with the effects. For example, you might want to style the third heading to have blue text so you'd do something like this:

h2:nth-of-type(3) {
color: blue;
}

h2 is the type of structural element whereas nth-of-type(3) means that you want to style the third of that type.