CSS syntax - Class, Id definition and tag redefine


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:4178

Bookmark CSS syntax



AddThis Social Bookmark Button

Step 2 - Class, Id definition and tag redefine


CSS syntax

There are more way how to define a style for a HTML element/section.

Let's see what does this mean.

Define a class

You can define a class for each HTML element by using the class property. In a HTML document you can use as many classes as you want and you can use the same class for any HTML element. See the example below:

Code:
  1. .boldText {
  2. font-weight:bold;
  3. }
  4.  

As you can see here in the CSS definition we used a dot before the class name!

Use an Id 

In a HTML document you can assign an Id to each of your HTML element, but you can use an id only at once inside the document. The example in this case is similar but here we used # sign in CSS definition.

Code:
  1. #mainArea {
  2. color: #999999;
  3. }
  4.  

Redefine HTML elements 

At least you can redefine the default style of any html element by simply create a new CSS class for it. In this case you don't put any sign before the name as here:

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




Previous Step of CSS syntaxNext 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
Flash F1
HTML F1
Java F1
JavaScript F1
PhotoShop F1
PHP F1
Windows F1
 
 
MaxTutorial
Monthly mortgage payment calculator
WebFormGenerator
Alpari forex

Total time: 0.3103