Start learning with our library of video tutorials taught by experts. Get started
Viewers: in countries Watching now:
In XHTML and HTML Essential Training, Bill Weinman helps designers and coders understand XHTML and HTML. In the process, Bill covers document structure, block and inline-level tags, floating images, controlling white space, phrase and font markup, and tables and frames. He even provides a good introduction to CSS. Bill offers step-by-step guidance for building a complete working web site. Exercise files accompany the course.
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.
Find answers to the most frequently asked questions about XHTML and HTML Essential Training.
Here are the FAQs that matched your search "":
Sorry, there are no matches for your search ""—to search again, type in another word or phrase and click search.
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.