In this lesson we will explore Absolute vs. Relative file referencing.
The concept is best illustrated with an example.
In our last exercise we inserted a video into our html page.
We did so using the
<video> element, which required a src attribute.
We have also worked with source attributes when inserting images.
The source attribute requires that we specify the source location and name of the file we want to insert into our document.
Since the files we've inserted to this point are in the same folder as the html file, we only had to specify a file name.
This is an example of relative file referencing. The path of the file, is defined relative to its directory.
Now say for example, we wanted to insert an image in this document from an external source, for example another website.
For that, we would need to use Absolute file referencing.
An absolute file path, requires that we include the complete address of the file as shown in this block of code.
<img src="http://www.planwallpaper.com/static/images/i-should-buy-a-boat.jpg" alt="Mountain View" style="width:900px;">
In the code block above, we have included a .jpg file from an external website (planwallpaper.com). The full URL to the file was required for the image to be displayed.