CSS Syntax
Example
CSS example
A CSS rule consists of two main parts: a selector, and one or more declarations:

A selector is usually the HTML element you want to style.
Each declaration consists of a property and a value.
A property is the style attribute you want to set. Each property has a value. The property and value are separated by a colon.
CSS example
CSS declarations always end with a semicolon ;, and declarations are always enclosed in curly braces {}:
p {color:red;text-align:center;}
To make CSS more readable, you can describe only one property per line:
Example
p
{
color:
red
;
text-align:
center
;
}
Try it »
CSS Comments
Comments are used to explain your code and can be edited freely; the browser ignores them.
CSS comments begin with /* and end with */, as shown in the following example:
Example
/*
This is a comment
*/
p
{
text-align:
center
;
/*
This is another comment
*/
color:
black
;
font-family:
arial
;
}