SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Addict
    Join Date
    Feb 2003
    Location
    eez
    Posts
    331
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Should I write <a href="..."><em>text</em></a> or <em><a href="...">text</a></em>?

    Hi!

    Should I write <a href="..."><em>text</em></a> or <em><a href="...">text</a></em>?

    Thanks

  2. #2
    Robert Wellock silver trophybronze trophy xhtmlcoder's Avatar
    Join Date
    Apr 2002
    Location
    A Maze of Twisty Little Passages
    Posts
    6,316
    Mentioned
    60 Post(s)
    Tagged
    0 Thread(s)
    Probably the former but it might be better to actually use CSS.

  3. #3
    Caveat surfer Buddy Bradley's Avatar
    Join Date
    May 2003
    Location
    Cambridge, UK
    Posts
    2,366
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't think it really matters, other than how you apply CSS to those nested elements - my personal preference would be to do it the first way, though.

  4. #4
    SitePoint Wizard bronze trophy DaveWoods's Avatar
    Join Date
    Dec 2004
    Location
    Derbyshire - UK
    Posts
    2,651
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Both are correct as far as HTML goes as they are both inline elements so either way will validate although I've probably do it the first way but that's purely personal preference.

    It's probably also worth mentioning that you should only use <em> if the word does actually need emphasis and you aren't just using it to make it look italic? If you want it to appear italic then font-style: italic would be much more appropriate

  5. #5
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,159
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The difference between those two examples is negligible. <a><em></em></a> is a link where the link text is emphasised. <em><a></a></em> is an emphasised word or phrase which is also a link.

    It's down to what you want to ... er ... emphasise (sorry!). If the important thing is that it's a link, use <a><em></em></a>. If the important thing is that it's an emphasised word or phrase, use <em><a></a></em>.
    Birnam wood is come to Dunsinane


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
  •