XHTML Tutorial: Standards-Based Web Design

by Paul Bohman

Links to the Index Page of a Folder or Web Site

When linking to the main file ("home page") in a folder, you can drop the file name entirely. Let's pretend that this is the file structure of our web site:

At the bottom of this list of files is a file called index.html. This is the home page for the whole web site. When we type the web address of this site (let's pretend the site's address is http://www.mysite.com/), we could either type http://www.mysite.com/ or http://www.mysite.com/index.html. Either one would work because the web site has already been set up so that all files named index.html will be the default file of their respective folders.

The index.html file on the top level is the home page for the whole site, but notice that most of the folders have their own index.html file. You could sort of say that each index.html file is the "home page" of their respective folders. For example, you could type http://www.mysite.com/about_us, but you could also type http://www.mysite.com/about_us/index.html. Both of these links will go to the same place.

However, it is important to note that not all web sites are set up in exactly the same way. Sometimes the default "home page" is index.htm (without the "L" at the end). Sometimes it is default.html, or index.php, or index.jsp, or some other name. The truth is that it could be called bananas_are_yellow.q7v or any other outlandish name if someone decided to do that on the server. For the most part, though, index.html or index.htm are the most common. Only the web server administrator has control over the name of the default file. If you're not the web server administrator, you'll have to accept the way that it was set up.

When creating links to default pages, it's a good habit to put a slash at the end of the link, so that the browser (and web server) know that you are referring to a folder and not to a file. The example links below include various kinds of both relative and absolute links. The important point to notice is that each of these references a folder, rather than a file.

Links to default pages in folders:

<a href="http://www.somesite.com/products/">the products page</a>

<a href="http://www.somesite.com/products/mousetraps/">Mouse traps</a>

<a href="../products/">the products page</a>

<a href="../products/mousetraps/">Mouse traps</a>

<a href="products/">the products page</a>

<a href="/products/mousetraps/">Mouse traps</a>

etc.

Creative Commons License
This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 2.5 License.