The Parts of a CSS Rule

rule parts
RuleThe whole thing is called a rule
Selector"h2" is the selector and determines what the rule applies to
Declaration I commonly call these "property-value pairs". These are the actual effect of applying the rule to an element.
  • remember your semicolons after each property (to separate declaration)
  • the value should be without spaces unless it is one of the few multi-value properties,
    "5pt" vs. "5 pt"
  • The whole block, the curly braces and everything in bewteen, is called a declaration block({...})

You would only find a rule in a stylesheet, either an internal or an external stylesheet. You will find properties in local styles. Local styles of course don't need selectors since the styles are applying to element the style attribute is in.

Back to Knowledge Dump