Great Templates

FEATURED WEB TEMPLATES

Amazon Books

Learn PHP

PHP Training
Zend Cert Training Zend Certified Engineer Zend PHP Pro

CSS Cascading Style Sheet: CSS Syntax

Syntax

Selector

The CSS syntax is made up of three parts: a selector, a property and a value.

The syntax : 

selector {property: value}

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.

body {color: black}

 

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:

h1,h2,h3,h4,h5,h6 
{
color: 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:

p.right {text-align: right}
p.center {text-align: center}

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.

An ID attribute must be unique within the document.

The style rule below will match a p element that has the id value "para1":
 

p#para1
{
text-align: center;
color: red
}

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 "*/" .  


 


Learn PHP | Zend Certified Engineer | Zend PHP Pro | PHP Web Apps | Web Hosting Service | Low Cost Domain Names | Great Templates | Great Books | Testimonials | Tech.Articles | TOS | AUS | Home | Linux Apache MySQL PHP