Menu highlight trick (CSS) - HTML / Javascript Tutorials
 
  Buy Ebooks, Video Games, DVDs, Electronics and more !
Home | Help Forums | Web Design Tutorials | Free Swishmax Downloads Make Money Online Blog . Free Image and Photo Sharing and Hosting

 

 

Company

Home

Nework Details

Tutorials

SWiSH 2

SWiSHMax

Flash MX

PHP & MySQL

HTML / JScript

Adobe Photoshop

Corel Draw

Gimp

Miscellaneous

Downloads

Templates

Plugins

Fonts

Wallpapers

Free Images

Scripts and Codes

Products

E-Books

SWiSH BB

SWiSH Templates

SWiSH-DB Newsletter
Subscribe to our newsletter : GO
  Partners / Affiliates

   Free image hosting
   Web Design Pakistan
   Swish Templates
   SWiSH Climax
   Talkfreelance Community
   Template Desire
   Lite boards
   Script Sector
   GimpTalk
   13dots
   Idea Designs
   PHP Cafe
   Sposatoettore
   Free swishmax templates
   Swishzone

Manage your site with Flax Article Content Management System
Menu highlight trick (CSS)
Category : HTML / Javascript | Level : Beginner | Language : English
Ask Question | Read Comments | Post tutorial | Previous | Next

Web www.swish-db.com

Hi,

I've just discover something interesting with css. Let assume i have a menu and with index, contacts and links items. I want the link of the current page to be different. here what i do with cascading style sheet.

CODE
<body class="linkcontact">
<div>here a list of contact</div>

<div class="menu">
<a id="linkindex" href="index.html">Index</a><br>
<a id="linkpage" href="links.html">Links</a><br>
<a id="linkcontact" href="contacts.html">Contact</a>
</div>

here i have defined the body class to be linkcontact, this keywords define the content of the page and could be also linkpage, or linkindex in my example.

Then i use attribute id to specify my links, to be more easy to read i reuse the same keyword as those use in the body class for each link linked to a page.

--
then in the style section
CODE
<style type="text/css">
.linkindex #linkindex, .linkcontact #linkcontact, .linkpage #linkpage {
color: red
}
</style>


the ".something" match any element of class something.
the "#something" match ay element of id something.
".something #somethingelse" match any element of id somethingelse enclosed by any element of class something.
Got it, the only link that will be color red will be the one which is id is used in the body class. So in my example above, only Contact will be red. to have Index in red, use
CODE
<body class="linkindex">...</body>



regards,
Sébastien




© 2002-2005 Flaxweb Network | Article Manager | Gimp Tutorials Library | RAD C++ Library | Free C/C++ Sourcecode |
Sites of interest : Web Design Blog | Swish Templates | Swishmax Ebook | Photoshop Templates | Gimp Tutorials | Text Forum | Make Money Online