Use Multiple CSS Classes


Did you know you can use multiple css classes in an html element? I'm sure you knew that, but in any case, here's an example of how someone might have done this in the past:

<style type="text/css">
.e {color:red; font-size:12px;}
.eBold {color:red; font-size:12px; font-weight:bold;}
</style>

Here is some error text
Here is some bold error text

But now, you can do this with much more ease... The second class will inherit/overwrite anything mentioned in the first class.

Here we will inherit:

<style type="text/css">
.e2 {color:red; font-size:12px;}
.eBold2 {font-weight:bold;}
</style>

Here is some error text
Here is some bold error text

Here we will overwrite:

<style type="text/css">
.e3 {color:red; font-size:12px;}
.eBold3 {color:green}
</style>

Here is some error text
Here is some green error text

This is a simple example, but the possibilities are endless. Ideas for use would be creating classes for specific criteria: errors, small text, important text, required textbox fields, images with borders, distinct links... and the list goes on.


User login

Who's online

There are currently 0 users and 0 guests online.

Latest Articles

Powered by Drupal - Design by Artinet - © 2007 SEO Cactus