Results 1 to 8 of 8

Thread: Different colour links in the same page?

  1. #1
    Join Date
    Feb 2005
    Posts
    71
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Default Different colour links in the same page?

    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:

    HTML Code:
    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?

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    There are various ways but, for your situation I'd suggest creating an extra class or more for links:
    Code:
    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:
    HTML Code:
    <a href="some.htm">Black Link</a>
    The other would be red with underline, written this way:
    HTML Code:
    <a class="red" href="someother.htm">Red Link</a>
    The word 'red' as a class identifier is arbitrary.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Dec 2004
    Location
    UK
    Posts
    2,358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by jscheuer1
    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.


    Quote Originally Posted by robertsaunders
    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

  4. #4
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Quote Originally Posted by mwinter
    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?
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  5. #5
    Join Date
    Dec 2004
    Location
    UK
    Posts
    2,358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by Twey
    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.

    HTML Code:
    <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
    Last edited by mwinter; 06-26-2005 at 03:56 PM. Reason: Typos

  6. #6
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Post

    Does it strike anyone as slightly ironic that the most used browser isn't standards-compliant?
    The amount of times you see:
    HTML Code:
    <!-- For IE: -->
    code
    <!-- For everything else: -->
    code
    I just can't understand how people can still insist IE is better.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  7. #7
    Join Date
    Dec 2004
    Location
    UK
    Posts
    2,358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by Twey
    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.

    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

  8. #8
    Join Date
    Feb 2005
    Posts
    71
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Default

    Thanks that is v helpful indeed. This forum is great isn't it?

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •