The syntax for CSS is
selector {property : value}
where selector is any HTML element. Each selector can have
multiple properties and each property can have multiple values. Multiple values
are separated by commas and if value contains more than one word than those
words should be inside two quotation marks.
e.g.
p{ text-align : center; color : maroon; }
Paragraphs of a web page using above code will be displayed
in center and maroon color.
You can also combine multiple HTML elements within one
selector:
h1,p{color: green;}
A web page using above code will display h1 headings and
paragraphs in green color.
You can comment CSS code like this:
/* your comments */
Example
<html>
<head>
<style type="text/css">
/* heading 1 will be displayed in green */
h1{color:green;}
/* All text of this page will be center aligned */
body{text-align:center;}
/* Color of horizontal line is blue*/
hr{color:blue;}
</style>
<title>
CSS syntax demo
</title>
</head>
<body>
<h1>CSS syntax demo</h1>
<hr>
<p>This is an example</p>
</body>
</html>
View output here