Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    Senior Coder effpeetee's Avatar
    Join Date
    Feb 2007
    Location
    Clapham Junction - London SW
    Posts
    4,885
    Thanks
    228
    Thanked 204 Times in 203 Posts

    What does / and # in href "#" or "/" signify

    What does / and # in href "#" or "/" signify?
    I have come accross them in some posters codes and cannot find the answer on Google or in my books.

    Frank
    * Sources (updated: 21.11.2012.
    Using Windows 8 Professional. 64bit with HP Photosmart 5510 printer Very useful site here.

  • #2
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,703
    Thanks
    6
    Thanked 1,011 Times in 984 Posts
    The forward slash is used to denote the root directory, i.e. (a link with) a URL containing a leading slash like “/images/example.jpg” is an absolute URL that tells the browser to look for the image starting at the site root. It works the same way if you leave the rest off and just have the slash. I.e. a link like this: <a href="/">Home</a> would bring the visitor to the default file (typically the index page) of the root directory in the same way as a link like <a href="/test">Link</a> would bring the visitor to the default/index file of the /test directory.

    The number sign in anchors is commonly used for links that aren’t supposed to go anywhere. Usually the number sign is a separator for a fragment identifier, i.e. a link <a href="#comments>comments</a> will bring the visitor to the element/section of the current page that has the ID “comments” (e. g. <div id="comments">…</div>).

    So, links that aren’t supposed to go anywhere are usually filled with a single number sign (for example for links that open new windows using javascript). However, I’ve read somewhere that this shouldn’t be done as it causes accessibility issues etc. I just can’t remember where I’ve read that.

  • #3
    Senior Coder effpeetee's Avatar
    Join Date
    Feb 2007
    Location
    Clapham Junction - London SW
    Posts
    4,885
    Thanks
    228
    Thanked 204 Times in 203 Posts
    Thank you VIPStephan. That clears that up for me.

    Frank
    * Sources (updated: 21.11.2012.
    Using Windows 8 Professional. 64bit with HP Photosmart 5510 printer Very useful site here.

  • #4
    Senior Coder ahallicks's Avatar
    Join Date
    May 2006
    Location
    Lancaster, UK
    Posts
    1,134
    Thanks
    1
    Thanked 57 Times in 55 Posts
    I remember being told that using something such as '#n' in your links (that aren't supposed to go anywhere) stops the page jumping to the top, but is not semantic code because you are basically pointing to the location of a div that doesn't actually exist
    "write it for FireFox then hack it for IE."
    Quote Originally Posted by Mhtml View Post
    Domains are like women - all the good ones are taken unless you want one from some foreign country.
    Reputation is your friend

    Development & SEO Tools

  • #5
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,642
    Thanks
    0
    Thanked 649 Times in 639 Posts
    The # is actually a link to the top of the current page (anyone using it for links that are not supposed to go anywhere is using it incorrectly).

    If the # is followed by something then that something is the id of the anchor point within the page that the link goes to. eg. #bottom puts the spot where <a id="bottom"></a> appears at the top of the screen (or as close as possible in there is insufficient content below it to fill the screen).
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #6
    The Apostate Apostropartheid's Avatar
    Join Date
    Oct 2007
    Posts
    3,215
    Thanks
    16
    Thanked 265 Times in 263 Posts
    Not necessarily an anchor. Anything which takes an ID may be pointed to by a fragment identifier.

  • #7
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,642
    Thanks
    0
    Thanked 649 Times in 639 Posts
    Quote Originally Posted by CyanLight View Post
    Not necessarily an anchor. Anything which takes an ID may be pointed to by a fragment identifier.

    True for modern browsers. Older browsers required that it be an anchor and so using an anchor tag for it will work in more browsers.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.


  •  

    Posting Permissions

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