Browse DevX
Sign up for e-mail newsletters from DevX


Twelve Dynamic HTML Lessons : Page 3

From Cascading Style Sheets to higlighted text to toggling images on and off the page, here are twelve fancy things that you can learn to do today in DHMTL.

The Class System
Many times you'll discover that you need variations of certain styles. For instance you might need two different styles of anchors, one that is the default style, and another with a variation for a different section of the same page. You might, for example, want it with a different background color used as a highlight. With classes, these variations are simple to set up. Here's what your style declaration might look like if you were creating a class of anchors named "highlighted":

<style type="text/css">

A.highlighted {background-color: ffff00}

Notice that the class declaration is just like a normal declaration except that ".highlighted" is appended to the HTML tag name. In this case we've created a new class of anchor named "highlighted." Once we've set up a class, it's easy to call it in an HTML page. Here's how:

<a class="highlighted" href="classsys.html">A highlighted link</a>
And here's what it looks like:

A normal link

A highlighted link

Simple and very convenient when you need variations on a particular tag. Classes are applicable to everything, <p>'s, <pre>'s, and any other tag whose style you need to control.

Thanks for your registration, follow us on our social networks to keep up-to-date