CSS Cascading Style Sheet: CSS SyntaxSelector The CSS syntax is made up of three parts: a selector, a property and a value. The syntax :
The selector is normally the HTML element/tag you wish to define, the property is the attribute you wish to change, and each property can take a value. The property and value are separated by a colon and surrounded by curly braces.
Grouping of Selectors You can group selectors. Separate each selector with a comma. In the example below we have grouped all the header elements. Each header element will be red:
The class Selector With the class selector you can define different styles for the same type of HTML element. Say that you would like to have two types of paragraphs in your document: one right-aligned paragraph, and one center-aligned paragraph. Here is how you can do it with styles:
The id Selector The id selector is different from the class selector! While a class selector
may apply to SEVERAL elements on a page, an id selector always applies to only
ONE element.
CSS Comments You can insert comments in CSS to explain your code, which can help you when you edit the source code at a later date. A comment will be ignored by the browser. A CSS comment begins with "/*", and ends with "*/" . |