CSS highlight menu item based on page body tags
Posted
by Sai
on Stack Overflow
See other posts from Stack Overflow
or by Sai
Published on 2010-05-18T15:20:08Z
Indexed on
2010/05/18
16:00 UTC
Read the original article
Hit count: 233
css
I have a menu, I would like to highlight the sub menu item based on the page they are in. Can I use a div tag with an id on the page, and in css if the id is there then highlight the item.
in body
<div id="doc3"></div>
then in css
#doc3 #menu li#subnav-5-1 a
I tried this but dosent seem to work. How can I change the style of another element based on id in the page body?
menu...
<!-- Menu 5 -->
<li id="nav-5"><a href="ssslate.do">Micro</a>
<ul id="subnav-5">
<li class="subnav-5-1"><a href="asdf.do">Site & Visit</a></li>
<li><a href="ss.do">MIC</a></li>
<li><a href="ss.do">sss</a></li>
</ul>
</li>
CSS
body.nav-5-1 li.subnav-5-1 {background-color:red;}
htmlbody
<body id=nav-5-body class="nav-5-1">
Thanks
© Stack Overflow or respective owner