All Posts by Email, Once a Week

Media Temple logo

CSS-Tricks is brought to you in part by Media Temple, the web hosting that we both use and recommend.

Linking HTML pages…which method is better?

  • # May 7, 2013 at 4:49 am

    Hi,

    This seems to be a rather simple question, but I haven’t really thought about it until recent. So here goes…

    Of the two methods below…which is considered better practice for linking between html pages?

    Page 2

    Page 2

    Thanks

    # May 7, 2013 at 4:58 am

    This reply has been reported for inappropriate content.

    I’d go with the third option:
    <a href="/page/2.html">Page 2</a>

    The difference is that it’s relative to the root, so you can move the file that the link is in without breaking the link, and move the website. To show the difference, assume a file structure like the following:

    index.html
    -page
    1.html
    2.html

    If you use 1 and move it from website.com to website2.com, you have to go through the files and change all the links.

    If you use 2, the link is “page/2.html” in index.html and “2.html” in 1.html, which to me makes it less consistent.

    If you use 3, you can use the same link no matter if it’s in index.html or page/1.html or page/something/other/file.html

    (And thorough answer to be helpful for those who are more newbie than you)

    # May 7, 2013 at 6:00 am

    This reply has been reported for inappropriate content.

    Thank you…I was confused for a moment…

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.

There's a whole bunch of content on CSS-Tricks.

Search for Stuff   •   Browse the Archives

Get the Newsletter ... or get the RSS feed