]> CSS Selectors | Web Developer Reference Blog

CSS Selectors

Thursday, February 25th, 2010

selector {property: value} – the selector is one of three things, the id of a single element that this style effects indicated by a #, the class used on many elements indicated by a . or the element itself, effecting all of the element named, the type selector.

Examples:

  • ID – #container {float:left;} causes the element with the id container to float left
  • Class – .red { color:red;} causes all elements in the red class to have red text
  • Type – body {font-family: Verdana, Tahoma, Arial;} causes all text within the body element to use the Verdana font face or Tahoma if Verdana is unavailable or Arial if Verdana and Tahoma are unavailable