CSS
  1. CSS intro
  2. CSS stylesheets
  3. CSS syntax
  4. CSS Classes & ID's
  5. CSS comments
  6. CSS BG properties
  7. CSS text properties
  8. CSS font properties
  9. CSS list properties
  10. CSS border properties
  11. CSS margin properties
  12. CSS padding properties
  13. CSS outline properties
  14. CSS table properties
  15. CSS dim properties
  16. CSS class properties
  17. CSS position properties
  18. CSS pseudo classes
  19. CSS pseudo elements
  20. CSS shortcuts
  21. CSS media types
  22. CSS summary

CSS syntax

CSS follows a specific syntax to define styles.

This tutorial 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.

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

Example of value being more than one word:
h2 {font-family: "Trebuchet MS"}

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

Example of multiple properties:
body {background-color: gray; color: 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.

© Copyright 2013-2014 Landofcode.com
Terms of use | Privacy policy | Copyright information