CSS
CSS introduction
Stylesheets
CSS syntax
Classes and ID's
CSS Comments
BG properties
Text properties
Font properties
List properties
Border properties
Margin properties
Padding properties
Outline properties
Table properties
Dim properties
Class properties
Position properties
Pseudo classes
Pseudo elements
CSS shortcuts
Media types
Summary

Programming

Programming intro
Java

Markup

First webpage guide
HTML
XHTML

Browser scripting

Javascript
VBScript
AJAX

Server scripting

PHP
ASP

Making money online

Make money online

CSS syntax

CSS follows a specific syntax to define styles.

This lesson focuses on:

CSS syntax

There are three parts in the CSS syntax:

selector {property: value}

Example:

body {background-color: gray}

The property and value of a selector are separated by a colon, and sorrounded by curly braces.

NOTE: If a value is more than one word, put quotes around it.

Example:

h2 {font-family: "Comic Sans MS"}

NOTE: If you specify more than one property, each property should be separated with a semicolon.

Example:

body {background-color: gray; color: yellow;}

This example specifies that the background color of a webpage should be gray and its text color should be yellow.

You can make style definitions more easily readable by specifying each property on a separate line.

Example:

body{
background-color: gray;
color: yellow;
margin-top: 0;
}

Grouping styles

You can specify that a group of tags will have the same styles by grouping them together.

Example:

p, h1, h2, h3, h4{
color: blue;
font-family: courier;
}

In this example, all text declared with the tags <p>, <h1>, <h2>, <h3>, and <h4> will be blue in color and Courier in font.

Practice

Online code editor
Practical examples
Practical exercises
Step-by-step tutorials

Reference

Terms glossary
Reference material

Rate this site

Rate this site
Visitor comments