What is CSS Syntax ?
A CSS rule has two main parts: a selector, and one or more declarations…
The syntax for CSS is different than that of (X)HTML markup.
Though it is not too confusing, once you take a look at it.
There are 3 important part of syntax or in writing to the CSS are:
Selector {property1: value1; property2:value2;}
- Selector,is an HTML tag like (div, p, div, table, td, th, and so on ..)
This tags will be given effect by the property and its value so that any format that we want can be achieved with CSS.
Try to note the example below:
<style type="text/css">
p: {color:red;}
</style>
From the example above, the selector is the Tag P, Tag P are HTML tag that make up a paragraph on a Web browser, so when Tag P given a property (color) and value (red), and then if we look on the browser, will display Text with Red color.
- Property:Value, is the essence of style that determine the effects of the selector, if you want to have a selector that background color?, background image?, underlined?, or a striped top?.
From the example above, which is color property, property should be placed amid signs that the {…} while value is red.
Among properties with values separated by a colon (:) while to obtain the property in a style definition, we use a dot coma (;) as Value.
Example:
p {color:#FFFFFF;
padding-top:10px;
font-size:12px;
}