Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
So, in our last lesson, we learned about relative URLs and in this lesson we're going to talk about how you can change the base of the relative URL. In other words, we learned that relative URLs are relative to the location of the document that has a link in it. But you can actually change that by using the base tag. The base tag goes in the head section and here is the base tag here and all this does is it specifies a location that all the URLs in this document are going to be relative to and again this file is available on my web server.
I'm actually using a local copy of it, because it can illustrate the same point. You'll notice in the browser here that this file is on my local machine at a file URL. Yet when I hover my mouse over this link, you'll see at that bottom. It's a link on the server and yet if you look at it in the text editor that this link, it doesn't have that whole http part of it. That's in the base and so it takes this and it uses this as the base for the relative URL and so this relative URL will start with the xhtml-links/another directory.
Let's look at that again in the browser, and we see in the bottom in the Status bar down there that it shows that URL relative to the base URL at the top of the document. I'll go ahead, and I'll click on it and you'll see that the location bar in the browser will change and it will have that location on my web server. So, I went ahead and loaded this off of the web server, http://bw.org/misc/xhtml-links/another /yet.another.html and when I click on this link, it will actually take me back to the version of it that's on my server there.
But it's the same file with that base URL. So that's how the base URL works. It changes the base from which the browser will construct URLs based on a relative URL. So this relative URL is no longer relative to the location of this file, instead it's relative to this base URL that we've specified in the base tag, in the head element.
Get unlimited access to all courses for just $25/month.Become a member
82 Video lessons · 97501 Viewers
61 Video lessons · 84744 Viewers
71 Video lessons · 68922 Viewers
56 Video lessons · 101373 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.