CSS Syntax

CSS Syntax : Selector and Declaration

  1. Each CSS Document consists of CSS rules.
  2. Each CSS Rule Consists of two main parts РSelector & Multiple Declarations

Selector and Separator in CSS

1. Selector :

  1. HTML element to styled is called as Selector.
  2. Multiple Selectors having same declaration

2. Declaration :

  1. Each CSS rule can contain Multiple Declarations
  2. Each CSS declaration consists of a property and a value pair.
  3. Each CSS property have value associated with it.
  4. Each CSS Property is the style attribute you want to change.
  5. Each CSS property has a value.

Live Sample Example


Explanation :

  1. h1 is selector .i.e HTML element which we are going to style.
  2. color and text-align are the CSS declarations that have some associated value.

Summary : CSS Syntax

Selector h1
Declaration1 color
Value1 red
Declaration2 text-align
Value2 center