Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
Another very common function of links is to redirect users to pages in sites that are external to the site that they're currently on. These are referred to as absolute links, and we're going to take a look at the syntax of absolute links using the file absolute.htm, which you can find in the 04_02 directory. Okay, so there is not a lot going on in this site, but we do have this nice little line of the text right here that we want to be a clickable link. It says, "Visit lynda.com!" So what we're going to do is we're going to wrap this in an anchor tag, same way we did earlier.
So we're just going to use the a. And this time for the href attribute, we're going to resolve the link a little bit differently. Because we're not currently on the lynda.com site, we have to tell the browser to leave where we currently are and go out and find the server that hosts lynda.com. So to do that, we're going to pass the entire path to the site, including the protocol. So we're going to do http://. The protocol is required. You don't want to leave that off. Then I'm going to type in www.lynda.com. Now, if I wanted to go to a specific page or directory within lynda.com, I could just keep adding.
I could even type in parameters on the end of this. If you on a page, for example, that would accept some type of variable so that it displays certain content in certain way, you could go ahead and add that as well. All right! I'm going to go ahead and close the quotation marks there and we're going to go ahead and give this a title, and the title here is going to be visit lynda.com. And that's one of the things you want to do with titles is you want to make them as descriptive as you can so that when a screen reader or something like that else reads the title out, or somebody hovers over it, they get a little bit more information about that link and they know whether they want to click it or not. All right! I'm going to go ahead and save this and preview this in my browser. All right! So here is our link that we've just created.
When I hover over, I can see it says, "Visit lynda.com," and when I click on that it goes right to lynda.com, so it works perfectly. Now there is one thing I want to mention about this, however. You'll notice that it replaced what our current page was, and sometimes that's exactly what you want to do, but there are going to be other times when you want somebody, if you're giving them a link to an external site, you want them to maybe be able to browse on that site for a while and then come back without having to hit the Back button a million times. So to do that, you want to open it up in a new tab or a new window. Well, that's actually very easy to do. And if I go back into my link syntax, all I have to do is add one more attribute here, and the attribute that I'm going to add is target.
So I'm going to say target= and in this case I'm going to do _blank. And there are several values that you can use there. There are sort of preset keywords that you can use, but most of them refer to frames, which hardly anybody uses anymore. So the only one you really need to focus on is _blank and what _blank is is telling the user agent "I want to open this up in either a new tab or a new window." So the user agent will just use whatever preference it has. So again, I'm going to save this. Go back to my page and preview this in the browser again. Now this time when I click Visit lynda.com, you'll notice that it opens it up an entirely new tab and this page is still there.
So that's another option that you have when you're creating absolute links. So as you can see, linking to external sites, it's pretty straightforward. One thing that you need to be aware of, just be sure to check the link path very carefully and make sure the full path, including the protocol, is listed.
Get unlimited access to all courses for just $25/month.Become a member
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.