Syntax / Rules

CSS is made up of rules consisting of three parts:

  • Selector
    • HTML element that the style will be applied to
    • e.g. <h1>
  • Property
    • Style attribute of the element
    • e.g. color
  • Value
    • Corresponding value for the property
    • e.g. blue

 

 

The selector specifies which elements to style, and is followed by a declaration block that begins with a left curly brace { closes with a right curly brace } that contains the property/value pair declarations.

 

The property/value pair are separated by a colon and end with a semi colon.

 

Example:

h1color: blue; font-size: 2em; }

 

Save & refresh browser:

A very simple page

 

 

The syntax rules depicted using code:

iframe source*

Leave a Reply