A Note on Linking URL's
Written by Brian Ledebur
Declaring a document type
Many attributes for the tags we will cover require a URL. This is a path to a file, whether it be an image or another HTML file. There are actually three ways to express these paths that work in HTML.
- Relative: Relative paths are expressed in relation to the file they are in. If you are pathing to a file in the same folder, the file name alone will do: “contactus.html”. If we are pathing to a file in a subfolder, we need the folder name and a ‘/’ before our file name: “images/logo.gif”. We can continue to drill down into subfolders by repeating the “folderName/” format. If we need to back up a level (into a parent folder), we can prefix our path with the ‘../’ characters: “../images/logo.gif”.
- Site Relative: Site Relative paths are expressed in relation to the root of our site. They always begin with a ‘/’ to indicate to the browser we are starting at the root. From there we can specify subfolders and files in the same manner as relative links: “/images/logos/logo1.gif”.
- Absolute: Absolute links include the full “http://” and domain name. They appear exactly how they would in the address bar of your browser. They are useful to linking to pages or files on external sites: ”http://www.valenciawebstudio.com/ledebur/handouts.html”