CSS syntax


Home - Tutorials - CSS tutorials

In this tutorial I will show you how to use CSS in your projects to make it more flexible.

Tutorial info:


Name:CSS syntax
Total steps:3
Category:CSS tutorials
Date:2008-03-31
Level:Beginner
Product:See complete product
Viewed:481

Bookmark CSS syntax



AddThis Social Bookmark Button

Step 1 - The CSS syntax


CSS syntax

CSS syntax is quite simple, you only need to comply some basic rules. First in this article we will focus on the basic CSS class definition rules and then I will show you how you can integrate your new CSS rules into your website code.

The general CSS syntax is the following:

        selector { property : value }

and if you define more properties then you can use a format like this:

        selector { property1 : value1; property2 : value2; }

So if you want to change your links color and want to remove underline you can do the following. For better readability you can put every property in a new line:

Code:
  1. a {
  2. color: #aabbcc;
  3. text-decoration: none;
  4. }
  5.  

You can also change more selectors property at once separating them with commas.

Code:
  1. h1, h2, h3 {
  2. color: #aabbcc;
  3. }
  4.  

It can happen that you want to change a property only inside an other container. For example you only want to change your links inside a table. You can do this by define first your container and then the selector as here:

Code:
  1. table a {
  2. color: #00aa00;
  3. }

And of course you can define more style for an element by using class selectors. With this technique you can define for example different link style for your navigation area, table data and footer links.

Code:
  1. a.navi {
  2. color: #0000ff;
  3. }
  4.  
  5. a.footer {
  6. color: #ffff00;
  7. }
  8.  




Next Step of CSS syntax


Tags: css syntax, css basics, css syntax basics

CSS syntax - Table of contents
Step 1 - The CSS syntax
Step 2 - Class, Id definition and tag redefine
Step 3 - Integration of CSS styles

F1 Site Family
AJAX F1
CSS F1
Database F1
Forex F1
Flash F1
HTML F1
JavaScript F1
PhotoShop F1
PHP F1
 

 
MaxTutorial
Monthly mortgage payment calculator
WebFormGenerator
Forex mini accounts

Total time: 0.3174