New Feature: Playlist Center! Pick a topic and let our playlists guide the way.

Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member

Linking to external pages

From: Up and Running with HTML

Video: Linking to external pages

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.

Linking to external pages

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.

Show transcript

This video is part of

Image for Up and Running with HTML
Up and Running with HTML

49 video lessons · 25175 viewers

James Williamson
Author

 
Expand all | Collapse all
  1. 2m 12s
    1. Welcome
      55s
    2. Using the exercise files
      1m 17s
  2. 29m 30s
    1. Learning HTML
      2m 47s
    2. Choosing a code editor
      5m 2s
    3. Exploring basic HTML syntax
      8m 18s
    4. Do I need to learn HTML5?
      5m 6s
    5. Exploring HTML references
      8m 17s
  3. 35m 40s
    1. Exploring an HTML document
      5m 19s
    2. Working with doctype declarations
      4m 3s
    3. Examining the document head
      8m 20s
    4. Looking at the document body
      3m 21s
    5. Adding document structure
      8m 52s
    6. Lab: Coding a basic page
      3m 9s
    7. Solution: Coding a basic page
      2m 36s
  4. 1h 23m
    1. How does HTML format text?
      5m 51s
    2. Adding headings
      7m 24s
    3. Formatting paragraphs
      4m 54s
    4. Controlling line breaks
      3m 50s
    5. Creating lists
      10m 37s
    6. Emphasizing text
      6m 42s
    7. Displaying special characters
      5m 8s
    8. Controlling whitespace
      4m 35s
    9. Inserting images
      9m 20s
    10. Lab: Controlling page content
      13m 57s
    11. Solution: Controlling page content
      10m 55s
  5. 31m 54s
    1. Linking to pages within your site
      6m 45s
    2. Linking to external pages
      3m 2s
    3. Linking to downloadable resources
      2m 25s
    4. Linking to page regions
      8m 0s
    5. Lab: Creating Links
      5m 57s
    6. Solution: Creating Links
      5m 45s
  6. 40m 27s
    1. Examining basic table structure
      5m 10s
    2. Adding content to tables
      6m 20s
    3. Setting table attributes
      7m 42s
    4. Adding table captions
      4m 3s
    5. Defining table headers
      2m 13s
    6. Making table data accessible
      5m 46s
    7. Lab: Building tables
      4m 13s
    8. Solution: Building tables
      5m 0s
  7. 43m 23s
    1. Understanding the relationship between HTML and CSS
      4m 58s
    2. Creating inline styles
      4m 53s
    3. Exploring the style element
      5m 13s
    4. Basic font styling
      9m 24s
    5. Changing color
      4m 55s
    6. Taking styles further
      5m 24s
    7. Lab: Controlling basic styles
      5m 10s
    8. Solution: Controlling basic styles
      3m 26s
  8. 5m 44s
    1. Next steps
      2m 56s
    2. Additional resources
      2m 48s

Start learning today

Get unlimited access to all courses for just $25/month.

Become a member
Sometimes @lynda teaches me how to use a program and sometimes Lynda.com changes my life forever. @JosefShutter
@lynda lynda.com is an absolute life saver when it comes to learning todays software. Definitely recommend it! #higherlearning @Michael_Caraway
@lynda The best thing online! Your database of courses is great! To the mark and very helpful. Thanks! @ru22more
Got to create something yesterday I never thought I could do. #thanks @lynda @Ngventurella
I really do love @lynda as a learning platform. Never stop learning and developing, it’s probably our greatest gift as a species! @soundslikedavid
@lynda just subscribed to lynda.com all I can say its brilliant join now trust me @ButchSamurai
@lynda is an awesome resource. The membership is priceless if you take advantage of it. @diabetic_techie
One of the best decision I made this year. Buy a 1yr subscription to @lynda @cybercaptive
guys lynda.com (@lynda) is the best. So far I’ve learned Java, principles of OO programming, and now learning about MS project @lucasmitchell
Signed back up to @lynda dot com. I’ve missed it!! Proper geeking out right now! #timetolearn #geek @JayGodbold

Are you sure you want to delete this note?

No

Thanks for signing up.

We’ll send you a confirmation email shortly.


Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

   
submit Lightbox submit clicked
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.