Industry guru Dave Taylor offers free tech support on a wide variety of technical and business topics, including HTML, Apple iPhone, online advertising, Cascading Style Sheets, Web design, management, Unix, Linux, search engine optimization, online dating, Mac OS X, shell script programming and Microsoft Windows.

Get your containers right with CSS!

I've been beating my head against the wall (proverbially, at least) with what should be a simple CSS style issue: I want to change the color and style of some text links on a Web page. I've been trying this:
<style type="text/css">
.bl              { color: #000; font-weight:900 }
.bl a:link       { color: #0f0; }
.bl a:visited    { color: #00f; }
.bl a:hover      { color: #000; background-color: #ff6 }
</style>

<a href="uses.shtml" class="bl">Google Adwords and Overture</a>
but it wasn't working.

Dave's Answer:

Finally it dawned on me: the "anchor container" can't accept all CSS styles, so a quick change to this:

<span class="bl"><a href="uses.shtml">Google Adwords and Overture</a></span>
and *poof* it's all working properly.

The moral of this story: make sure that the containers you're using can accept the styles you're specifying.

Note that you can always pop over to W3C (aka the World Wide Web Consortium) and read the official CSS specification documents too, if you're so inclined.



Help others find this article at Del.icio.us, Digg, Netscape, Reddit, and Stumble Upon    

Subscribe!

Never miss another useful Q&A article again! Subscribe to AskDaveTaylor with Google Reader.

Comments

Isn't it because of the way the CSS is written? The given code says "take anchors _within_ an element of class 'bl' and set the given properties." If this code is this:

a.bl { color: #000; font-weight:900 }
a.bl:link { color: #0f0; }
a.bl:visited { color: #00f; }
a.bl:hover { color: #000; background-color: #ff6 }

It should work, no? Now it says "take anchors of class 'bl' and set the given properties."

Posted by: Mark at June 28, 2005 12:30 AM

I have something to say, now that you mention it, but ...
Starbucks coffee cup I do have a lot to say, and questions of my own for that matter, but first I'd like to say thank you for all your efforts on this Web site by buying you a cup of coffee!

I do have a comment, now that you mention it!











Remember personal info?


Please note that I will never send you any unsolicited commercial email. Ever.

While I'm at it, please note that by submitting a question or comment you're agreeing to my terms of service, which are: you relinquish any subsequent rights of ownership to your material by submitting it on this site.








Ask Dave Taylor: The iPhone App: Advertisement


Uniblue: Free Virus Scan

Follow me on Twitter @DaveTaylor

Search
Find just the answers you seek from among our 2300+ free tech support articles by using our Lijit search engine.


Help!





Subscribe to
Ask Dave Taylor!

Add to Google Reader
Add to My Yahoo!
Subscribe in NewsGator Online

RDF   XML

Free Updates!
Sign up and get free weekly updates and special offers on books, seminars, workshops and more.


Recent Entries
Book Links
© 2002 - 2009 by Dave Taylor. All Rights Reserved.

Note: This web site is for the purpose of disseminating information for educational purposes, free of charge, for the benefit of all visitors. We take great care to provide quality information. However, we do not guarantee, and accept no legal liability whatsoever arising from or connected to, the accuracy, reliability, currency or completeness of any material contained on this web site or on any linked site.

[whiteboard marker tray]
"Ask Dave Taylor®" is a registered trademark of Intuitive Systems, LLC.