Grow your CSS skills. Land your dream job.

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

    I’d go with the third option:
    `Page 2`

    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

    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.

*May or may not contain any actual "CSS" or "Tricks".