Print bookPrint book

READ: Relative vs. Absolute Paths

.

Site: Mountain Heights Academy OpenCourseWare
Course: Web Essentials Q1 v2014
Book: READ: Relative vs. Absolute Paths
Printed by: Guest user
Date: Tuesday, 17 April 2018, 4:09 PM

Intro

In this chapter we are going to learn about relative and absolute paths. As we learned in the last chapter, files are organized into folders or directories. A file's path is like an address for a file. It directs the computer to where a file lives. Files live in folders which live in other folders and so on. Its organized like a tree with multiple branches. The uppermost directory is the root directory like the root of the tree. Every other file is a descendant or child of the root. The root is separated by a '/'. 

One of the most common things newcomers to Webpage creation get confused about is linking to other pages, including CSS files, and referencing images. At the root of the confusion are absolute and relative paths. It’s important to understand the different between a relative and absolute path.

Relative Paths

A relative path assumes that the file is on the current server.  Using relative paths allows you to construct your site offline and fully test it before uploading it.

For example:

"php/webct/itr/index"

Go to the next link to learn about absolute paths.

Absolute Paths

An absolute path refers to a file on the Internet using its full URL. Absolute paths tell the browser precisely where to go. 

For example:

"http://www.uvsc.edu/disted/php/webct/itr/index" 

Absolute paths are easier to use and understand.  However, it is not good practice on your own website.  For one thing, using relative paths allows you to construct your site offline and fully test it before uploading it.  If you were to use absolute paths you would have to change your code before uploading it in order to get it to work. This would also be the case if you ever had to move your site or if you changed domain names.  

The video in the next link will explain all of this.

Video

Watch the video below.  It may seem kind of confusing as you are watching it, but I can assure you that it will make more sense in quarter 2 when we actually learn how to hyperlink files.  For now, pay attention to the differences between an absolute path and a relative path.  HERE is a good read on absolute and relative paths if you are interested.


CC By-NC 2007, Jared Stein. Web Essentials, http://jaredstein.org/courses/web-essentials/

Game

Play the game below until you feel you have a good understanding of absolute and relative paths.  
Relative_vs_Absolute_Paths-_Shootout_Game.swf