SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Member
    Join Date
    Jul 2009
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Post Linking to bookmark in FF and Safari

    I have the following bookmark link in my html code:

    Code:
    <a href="#alabama">Alabama</a>
    And then the bookmark location is:

    Code:
    <a name="Alabama">Alabama</a>
    This works in IE but not in Firefox or Safari.

    What is the correct way to link to a bookmark?

    Thanks,

  2. #2
    SitePoint Member
    Join Date
    Jul 2009
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Post

    Never mind. Missed the capital letter.

    #alabama does not equal name="Alabama"

  3. #3
    SitePoint Wizard bronze trophy C. Ankerstjerne's Avatar
    Join Date
    Jan 2004
    Location
    The Kingdom of Denmark
    Posts
    2,702
    Mentioned
    7 Post(s)
    Tagged
    0 Thread(s)
    You also have to use id="..." rather than name="...".
    Christian Ankerstjerne
    <p<strong<abbr/HTML/ 4 teh win</>
    <>In Soviet Russia, website codes you!

  4. #4
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,789
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    and it can go on any tag - you don't need to add an <a> tag to use it.

    The exception is if you need to support Netscape 4 where you do need to use <a name="xx"> for it to work there (and need the same id in the same tag for it to work in more modern browsers).
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  5. #5
    SitePoint Member
    Join Date
    Jul 2009
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Post

    I used name and that seems to work in FF, Safari, and IE8.

    Is id the correct method?

  6. #6
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The name attribute is deprecated – except for form controls – in some DTDs, which means W3C thinks you shouldn't use it.

    Using the id attribute is well supported in contemporary browsers, but not in really old (pre-HTML4) browsers. The advantage is that it's available for almost every element type, unlike name.
    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
  •