Jump to content

Assigning a class to specific text links to change their colour - help appreciated


Bert Coules

Recommended Posts

I've searched around for help on this problem but can't find anything that seems specifically relevant.

 

In the small and straightforward HTML5/CSS site that I'm designing offline, I want to change the colour attributes of text links according to what background they appear on. In the CSS file I have this as an overall command:

a:link   {color:#CCCCFF; background-color:transparent; text-decoration:none}

and so on, for visited, hover and active. This works perfectly and affects every link. I also have this, immediately following:

a.bluelink:link   {color:#8000080; background-color:transparent; text-decoration:none}

and so on, which I intended to work in conjunction with specific links such as:

<a class="bluelink" href="http://www.bbc.co.uk/cult/sherlock/coules.shtml" target="_blank">BBC Cult interview</a>

However, this doesn't produce any effect: the link remains in the overall-set colours. Am I overlooking something obvious, or do I simply have the wrong approach? Many thanks in advance.

Edited by Bert Coules
Link to comment
Share on other sites

Yes, the new class links are directly below the overall settings in the CSS file.

 

Many thanks for the suggestion about clearing the cache. I just tried it (I'm using Firefox) but unfortunately it's made no difference. The same thing is happening in Chrome.

 

I was going to mention this in another thread, but perhaps it's relevant here: I've just discovered that <p> </p> tags are also not working: text just runs on with no line breaks. Something odd seems to be going on somewhere.

 

As I said I'm working offline, using Notepad++ as an editor and EasyPHP as a viewer. But that shouldn't be making any difference, should it?

Edited by Bert Coules
Link to comment
Share on other sites

This isn't really progress, but I suddenly twigged that the code I was using for a.bluelink:link wasn't valid, largely because it consisted of seven digits and letters rather than six. Heaven only knows where I got it from or why I didn't notice sooner.

 

Unfortunately, changing it to a recognised six letter code (actually, #0000FF) has done nothing to fix the problem.

 

Edited to add:

 

Solved it! After I corrected the codes I tried things out with one particular page - which turned out to be generated by the only page file where I'd forgotten to add "class="bluelink" into the relevant links. Now the colours are working fine throughout the site. Many thanks to dsonesuk for reassuring me that the basic approach was the right one.

 

Those <p></p> tags are still misbehaving though. I'd keep investigating.

Edited by Bert Coules
Link to comment
Share on other sites

That's clever and handy, thanks.

 

I'm still feeling my way with all this stuff to a certain extent. I'll probably be asking some more fairly basic and/or naive questions soon and trying people's patience. But I'm grateful for the help and advice.

Edited by Bert Coules
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...