PDA

View Full Version : Different colour links in the same page?



robertsaunders
06-26-2005, 12:52 AM
I'm sorry if this is basic but I want to have different links on the same page with different style attributes, ie some links in red underlined, some in blue not underlined etc.

How do I do this? At the moment I have a separate style.css page with the following code which controls all the links on the page:


A:link {text-decoration:none; font-size:8pt; font-family: Verdana, MS Sans Serif; color:#000000}
A:visited {text-decoration:none; font-size:8pt; font-family: Verdana, MS Sans Serif; color:#000000}
A:hover {text-decoration:underline; font-family: Verdana, MS Sans Serif; color:#790000}

Any suggestions?

jscheuer1
06-26-2005, 02:52 AM
There are various ways but, for your situation I'd suggest creating an extra class or more for links:
A.red:link {font-size:8pt; font-family: Verdana, MS Sans Serif; color:red}
A.red:visited {font-size:8pt; font-family: Verdana, MS Sans Serif; color:red}
A.red:hover {text-decoration:underline; font-family: Verdana, MS Sans Serif; color:hotpink}The above, in addition to your current declaration would result in two types of links for your pages. One would be the black ones with no underline that you already have, written in the html like so:
<a href="some.htm">Black Link</a>The other would be red with underline, written this way:
<a class="red" href="someother.htm">Red Link</a>The word 'red' as a class identifier is arbitrary.

mwinter
06-26-2005, 03:13 PM
The word 'red' as a class identifier is arbitrary.To the OP: And should be changed. Class names should be semantic, not descriptive. For example, in the future you might want to change these links to a different colour, and 'red' would be a stupid name. Think why these links are different and use that.



font-size:8pt; font-family: Verdana, MS Sans Serif;[From other posts of mine, abridged:] Verdana is not usually a good typeface to use. The fact that it's too large at 'normal' sizes means that fallback fonts will end up being too small - unreadably so, most of the time. Similarly, micro-fonts are undesirable. Whilst they might look good in an asthetic sense, they are often difficult to read, which kind of defeats the purpose of publishing information: why bother if it can't be read? The font size should never go lower than 85% of the user default, and probably no less than 90-95% at an absolute minimum for body text. If the font still seems too large, then don't use it.

Another issue is that IE cannot resize fonts that use units, which is a potentially serious problem for users with poor eyesight. Use percentages instead.

Mike

Twey
06-26-2005, 03:25 PM
IE cannot resize fonts that use units, which is a potentially serious problem for users with poor eyesight. Use percentages instead.Is IE able to resize font sizes specified in ems?

mwinter
06-26-2005, 03:53 PM
Is IE able to resize font sizes specified in ems?Yes, but it gets it wrong. Horribly in some cases; moving between 'Text size' menu settings can cause large jumps in size. Nested font sizes exasperates the problem.


<p style="font-size: 110%;">The quick brown fox <span style="font-size: 110%;">jumps</span> over the lazy dog.</p>
<p style="font-size: 1.1em;">The quick brown fox <span style="font-size: 1.1em;">jumps</span> over the lazy dog.</p>
is a simple example. The word, 'jumps', should be 21% larger than the browser default, and just 10% larger than the rest of the text (so we're talking a couple of pixels). Clearly this doesn't happen with the em example, even with the unnested text.

Mike

Twey
06-26-2005, 06:27 PM
Does it strike anyone as slightly ironic that the most used browser isn't standards-compliant? :rolleyes:
The amount of times you see:
<!-- For IE: -->
code
<!-- For everything else: -->
codeI just can't understand how people can still insist IE is better.

mwinter
06-26-2005, 07:42 PM
Does it strike anyone as slightly ironic that the most used browser isn't standards-compliant?It goes a little further than irony, and standards-compliance for that matter, but best not go down that road. :mad:


I just can't understand how people can still insist IE is better.I don't remember the state of things back then (it was a few years ago after all), but it's alledged that IE, in all of its versions, was the best when it was released. But of course, stale software is junk in a field like the Web. Every other vendor constantly updates their software to correct bugs and move towards more predictable behaviour that helps developers, and in turn, Web users. Microsoft need to understand and appreciate the worth of this approach, and embrace standardisation in tandem with innovation. I doubt we'll see either in the next release. :(

Mike

robertsaunders
06-26-2005, 09:15 PM
Thanks that is v helpful indeed. This forum is great isn't it?