Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
HTML has a feature that allows you to specify a different base URL for use in resolving relative URLs. Let's make a working copy of base.html, and we'll call our working copy base-working.html, and we'll open that in the text editor. And we have a relatively small file. And if we open this up in the browser, you notice there's a link to page 1. And you'll notice, if you look at this link, it just says page1.html. And if you look here at our current URL in the location bar, it shows that we're in local file system, Chapter 7, base-working.html. But if I hover over this and you look down here at the bottom, it says it's looking for it on my server, ldc.bw.org/html-chap07/page1, like that.
And that's because of this base tag here. So what the base tag does is it gives the document some place else to base its relative URLs from. So when the browser sees this relative URL, instead of saying, well, where is my document and let me build the URL based on that, it's going to build it based on this location instead. And this location is on a different server, in a different state. So when I click on this, you'll notice that it brings up this page from my server instead: ldc.bw.org/html-chapter07/page01.
And when I link to page 2, see, it's all there on the server. Back to page 1. Even when we link back to the original document, we're not in our original document on the local file system; it's on the server instead. So this is a very powerful feature. It can be a source of confusion; it can be a source of problems when you're trying to figure out what's wrong with something. I recommend that if you ever use this feature-- and frankly, I've never actually used it-- if you ever use it, you do so very carefully and you document it very thoroughly, so that whoever comes along after you to try to figure out what happened, will know.
The base element allows you to specify the base URL for use in resolving relative links. This can be handy for development purposes, but I strongly recommend against using it in a production environment.
Get unlimited access to all courses for just $25/month.Become a member
82 Video lessons · 98243 Viewers
61 Video lessons · 85549 Viewers
71 Video lessons · 69504 Viewers
56 Video lessons · 101842 Viewers
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.
Your file was successfully uploaded.