g
Printer Friendly Version

editor  
BellaOnline's HTML Editor
 

Types Of CSS Rules

In the last tutorial, you learned that a CSS rule is made up of a selector, property and value. Now we will discuss the three types of CSS rules.

HTML Selector
You were introduced to this in the last tutorial. The HTML selector is derived from the alpha/numeric portion of an HTML tag. That is, the stuff inside the < >. For example, the HTML selector for the <p> tag is p. This type of CSS rule is used to control the way an HTML tag behaves on the webpage. In our example, the CSS rule will control how the text between the opening <p> and closing </p> tags will be displayed.

Class
The Class command can be applied to any HTML tag. In fact it can be applied to multiple HTML tags on a webpage which makes it the most versatile. Unlike the HTML selector which is derived from a part of an HTML tag, you can give the Class command any name you want (following the CSS naming limitations). For example, we can create a Class command that will give the text a blue color and name this Class command blue. We can apply this blue Class command to both the HTML table cell tag <td> and the paragraph tag <p>. Then the text in the table cell and the text between the <p> tags will both be blue.

ID
This type of CSS rule is usually used to create an object to be used with DHTML or Javascript. Like the Class command you can give it any name you want and it can be applied to any HTML tag. But it can be applied only once on a webpage.

♦♦If you are interested in creating a website with HTML, you might be interested in reading the HTML Basics Series which will teach you the basics of HTML as you build a simple three-page website and create a webpage template that you can use to add more pages to this site.

♦♦You might also want to try the Flash Basics Series that will walk you through the process of building a website with MacromediaR FlashR. If you are new to Flash or just need to refresh your skills, this is the place to start. This series of tutorials will give you the basic knowledge you will need to be able to create a simple Flash based website.




This site needs an editor - click to learn more!

HTML Site @ BellaOnline
View This Article in Regular Layout

Content copyright © 2013 by Diane Cipollo. All rights reserved.
This content was written by Diane Cipollo. If you wish to use this content in any manner, you need written permission. Contact Editor Wanted for details.



| About BellaOnline | Privacy Policy | Advertising | Become an Editor |
Website copyright © 2014 Minerva WebWorks LLC. All rights reserved.


BellaOnline Editor