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
Step 2 - Class, Id definition and tag redefine
CSS syntax
There are more way how to define a style for a HTML element/section.
- Define a class
- Use an Id
- Redefine HTML elements
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:
.boldText { font-weight:bold; }
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:
#mainArea { color: #999999; }
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:
a { color: #aabbcc; text-decoration: none; }
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 |