Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

CSS Selectors

CSS selector

h1 {
color: blue;
}
CSS selectors are the part that selects the HTML in order to
apply whichever rules go in between the {}.
The example above is called a Element selector.
The element selector selects all the elements that have the same
name (all h1).

Class selector

.red-heading {
color:red;
}
A class is something that we can add as an “attribute”to an
element.
A class selector can be used to multiple element so that the
same rule will be applied.

Id selector

#main {
color:blue;
}

Id vs Class selector
Class selector can be applied to many elements.
Id selector should only be applied to one element in a single HTML
file.
Attribute selector

p[draggable] {
color:red;
}

Universal selector

*{
color: red;
}

You might also like