CSS: Classes


You can build classes. All elements inside the 'body' element can be classed. For example:

<head><style type="text/css">
h1.myclass { color : red }
</style></head>

<body><H1 CLASS=myclass>This title is a red title</H1></body>

So you define a class for <h1> tags. This means that class affects only <h1> tags; <div> tags for example, won't be affected. So you can't write:

<body><p class=myclass>this is a wrong use of CSS</p>

You can specify only one class for tag. For example, you can't specify 2 classes for one tag:

h1.class1.class2 (this is wrong!)

If you don't specify the tag while you are defining the class, and you put a '.' before the class, the class itself won't be combined with a particular tag, but it will be usable for all tags. So, if you write:

.mycolor { color : red }

you will be able to use '.mycolor' wherever you want. For example:

<h1 class=mycolor>this is a line</h1>

<p class=mycolor>this is another line</p>


Index           Home  Back       About  Contact us!

Copyright (c) 1998-2006 Wowarea