[thelist] More CSS ignorance

M. Seyon evoltlist at delime.com
Wed Oct 27 12:00:28 CDT 2004


Message from Christian (10/27/2004 11:29 AM)
>Dear list,
>
>Thanks to all who've already been patient with me.
>
>How do I achieve multiple styles of link in CSS?  I want one style for my 
>top menu, one for my left menu, and one for links in the body text.

Hi Christian,

You can achieve this using classes or IDs. Here's one way.

Give each area of your page a unique id - #topmenu, #leftmenu #body, for 
example.

Then in your stylesheet you do something like this

#topmenu a
{color: red}

#leftmenu a
{color: blue}

#body a
{color: green}

These are called descendant selectors. Essentially you're saying apply the 
styles to the A element only if it's contained by the specified element.

Your HTML would look like

<div id="topmenu">
<a href=...>
</div>

<div id="leftmenu">
<a href=...>
</div>

<div id="body">
<a href=...>
</div>

I know you've asked a couple questions and gotten answers from thelist so 
it might be starting to look really easy to just come online with all your 
questions, but you'll really learn a lot more and understand CSS better if 
you invest some time in some proper CSS resources (books or website 
tutorials) and use the list to supplement that knowledge.

May I recommend a book that does an excellent job of walking you through 
the basics of combining HTML and CSS - HTML For the World Wide Web, 5th 
edition, with XHTML and CSS, Elizabeth Castro, ISBN 0321130073

Or if you're on a tight budget, here are two good online resources:
http://www.mako4css.com/
http://www.w3schools.com/css/default.asp

regards.
-marc

--
Trinidad Carnival in all its photographic glory. Playyuhself.com
http://www.playyuhself.com/


More information about the thelist mailing list