#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2003
    Posts
    2
    Rep Power
    0

    css and self-closing anchor tags


    I'm encountering an issue using css to format html that uses self-closing anchor tags

    ie <A name="risk" />

    Since there are several bookmark links at the top, these anchors are spread throughout the page. My styles for anchors are as follows:

    a { font-weight: normal }

    .body a { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; line-height: 14px; font-weight: normal; color: 3878db; text-decoration:underline }

    PROBLEM: The text following each <a name> tag is inheriting the anchor style. This is the case until an acutal </a> tag appears in the code.

    Is there another solution besides changing the the self closing acnhor tag to a standard tag <a name="risk"> </a>

    Thanks!
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    May 2003
    Posts
    1,014
    Rep Power
    15
    By adding the attribute selector [href] to the a in your style rules, the style will only be applied to those <a> elements for which an href attribute is defined...
    Code:
    .body a[href] { allstylestuff }
    Maybe this works for you?
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2003
    Posts
    2
    Rep Power
    0
    This fix seems to work in Netscape -- but not in IE5 or IE6. It seems that IE is not recognizing anything about the .body a style when I add the [href] attribute to it. It looks like it ignores it and just delivers the default style.

    Here is my style as it stands now:

    .body a[href] { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; line-height: 14px; font-weight: normal; color: 3878db; text-decoration:underline }

    Thank you very much for your reply!
  6. #4
  7. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2003
    Posts
    804
    Rep Power
    101
    I have found that all this talk about closing tags with /> is bs... it never works for me
    Just use the closing tag like you are supposed to do, and it will work fine. Why complicate things?

IMN logo majestic logo threadwatch logo seochat tools logo