Welcome to Our Free Tutorial!

CSS - Syntax

The CSS syntax have 3 rules a selector, a property, a value.


Selector {property: value}
The selector is the HTML element that you want to style.
h2 { Color: red}
This code tells the browser render all occurences of HTML h1 element in red.

Grouping Selectors

If you want to apply a style many selectors. You just do separate selectors with a comma.
h1,h2,h3,h4,h5,h6 { color: red }

Applying Multiple Properties

You can apply many property and more than one property separate each declaration with a semi-colon.
h1 { font-family:TimesNewRoman, Arial, Calibri,”sans serif” ; color: red}


If you want to make your CSS code spreading your style declarations in multiple lines. You can also write code if you like. This does not affect your code it just make easier for you to read.
h1 {
Color: red;
Font-family: TimesNewRoman, Arial, Calibri,”sans serif” ;