Page is a not externally linkable
- WebmasterWorld
-- New To Web Development
---- a:hover - how many can I have?


rewboss - 8:30 am on Aug 15, 2002 (gmt 0)


The possibilities are endless, actually. Class is the obvious solution (it's not a "workaround", this is how CSS is supposed to operate, despite what DW might tell you). Another elegant solution is the use of contextual selectors.

A fairly common situation is where you have most text links behaving in one fashion, but the links in a navbar (which might be on a different background) doing something different. You can put all your navbar links in a <div> with an id "navbar", then your style sheet will look a little like this:

/* First the styles for the "normal" links */
a:link { .... }
a:visited { .... } /* etc etc etc */

/* Now the styles for the navbar links */
#navbar a:link { .... }
#navbar a:visited { .... } /* etc etc etc */

Note: no comma after #navbar.

#navbar a is interpreted as: "Any a element that is nested inside a div element with an id of 'navbar'."

This allows you to drop the class attribute from the <a> tag:

<div id="content">
<a href="next.html">This will be a normal text link</a>
</div>

<div id="navbar">
<a href="next.html">This will be a navbar link</a>
</div>


Thread source:: http://www.webmasterworld.com/new_web_development/50.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com