CSS Selectors

There are many different types of selectors. The examples above use element selectors, which select all elements of a given type. But we can make more specific selections as well;

  • Element selector – selects all elements of the given type for <p>
  • ID selector – selects an element with a given id provided in the id attribute
  • Class selector – selects the element(s) on the page with the specified class. 
  • Attribute selector – selects the element(s) on the page with the specified attribute.
  • Pseudo-class selector – selects the specified element(s), but only when in the specified state. (For example, when a cursor hovers over a link.)

Element , ID & Class Selectors

Element , ID & Class Selectors

Attribute & Pseudo-class selector

Attribute & Pseudo-class selector
Attribute Selector

Scroll to Top