Using Document-Relative Paths

In a document-relative path, you give the browser directions to the desired page from the current Web page. You do this by stepping the browser through your site's hierarchy.

It stands to reason, then, to write a good document-relative path, you need to know the hierarchy of your site. Take the following site structure:

  • Home Page

    • Movies

      • Action

      • Comedy

      • Drama

      • Romance

      • Mystery/Suspense

      • Horror

      • Sci-Fi

    • Music

      • Popular

      • Jazz

      • Classical

    • Games

      • PC

      • Console

Say that the current page is the home page. A document-relative path to the Movies page from the home page looks like this:

<a href="movies/movies.htm">Home Page to Movies</a>

while a document-relative path to the Action page within the Movies category looks like this:

 <a href="movies/action/action.htm">Home ...

Get Web Design Garage now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.