CSS Syntax : Selector and Declaration
- Each CSS Document consists of CSS rules.
- Each CSS Rule Consists of two main parts - Selector & Multiple Declarations

1. Selector :
- HTML element to styled is called as Selector.
- Multiple Selectors having same declaration
2. Declaration :
- Each CSS rule can contain Multiple Declarations
- Each CSS declaration consists of a property and a value pair.
- Each CSS property have value associated with it.
- Each CSS Property is the style attribute you want to change.
- Each CSS property has a value.
Live Sample Example
h1
{
color:red;
text-align:center;
}
Explanation :
- h1 is selector .i.e HTML element which we are going to style.
- 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 |