Results 1 to 4 of 4

Thread: Stupid that I don't already know how...

  1. #1
    Join Date
    Jun 2005
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Stupid that I don't already know how...

    How do I make text (link to be exact) change color upon mouseover? Or should I not bother with the text and just make two images and js those for mouseover?

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

    Default

    Quote Originally Posted by GarrenNatas
    How do I make text (link to be exact) change color upon mouseover?
    For all links, use the following CSS:

    Code:
    a:link {
      background-color: ...;
      color: ...;
    }
    a:link:hover {
      background-color: ...;
      color: ...;
    }
    If you only have specific links in mind, then you'll obviously need to change the selector, either using the document structure, or a class attribute.

    For example, if the links were in a particular paragraph, you might use:

    Code:
    #paragraph a:link {
      /* ... */
    }
    #paragraph a:link:hover {
      /* ... */
    }
    where paragraph was the id attribute value of the p element.

    Using a class, you might have:

    Code:
    a.external:link {
      /* ... */
    }
    a.external:link:hover {
      /* ... */
    }
    with links like:

    HTML Code:
    <a class="external" href="...">...</a>
    Or should I not bother with the text and just make two images and js those for mouseover?
    No. In this case, CSS is much better for a couple of reasons.

    The first is that the text is resizable, which is a good accessibility bonus. Using images to present text can lead to sites that are hard to read for those with less-than-perfect eyesight, unless you're careful.

    The second benefit is that you don't rely on client-side scripting. Whilst CSS is optional just like scripts are, style sheets are disabled less often.

    The third is that using plain text requires much less traffic. A well-designed script will be at least a couple of kilobytes - the images will be too (and you'll have two per link). Finally you have the links in HTML. Compare that to just simple HTML and a couple hundred bytes in a style sheet, and the difference could be significant (depending on the number of links).

    Hope that helps,
    Mike

  3. #3
    Join Date
    Jun 2005
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thank you very much. I ended up going the CSS route and it worked perfectly.

    But... Now I have another issue and it's going to be basic HTML and it really should be something that I'm going to end up hitting myself for (especially since I probably learned this in high school), but how do I bottom align a background image? Is it possible to put a "valign" tag into the body or table tag after the "background=..." or would that just screw everything up more??? If you can, I could use an answer on this ASAP. THANKS!

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

    Default

    Quote Originally Posted by GarrenNatas
    [...] how do I bottom align a background image?
    You need to use CSS again:

    Code:
    selector {
      background: color url(image) left bottom;
    }
    There are obviously things you'll need to change there (selector being the most important). You might also want to align the image differently horizontally - other values[1] are center and right. If you don't want to have the background repeated, then add one of the repeat-x, repeat-y, or no-repeat keywords.

    Hope that helps,
    Mike


    [1] You can also use percentages. For instance, 0% 100% is equivalent to left bottom.

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
  •