About CSS Syntax

Syntax is like grammar: rules of language.

  • A CSS rule has two main parts:
    • The selector
      — Selects tags where the rule applies
    • declaration block containing one or more declarations
      — Declaration block is a pair of curly braces {}
      — Each declaration has a property and value, separated by a colon (:)
      — Each declaration ends with a semicolon
  • Example:
    CSS syntax
  • The above example select <h1> tags, making them blue and setting their font size to 12px;
See also