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

Working with hyperlinks

From: XHTML and HTML Essential Training

Video: Working with hyperlinks

In this chapter we are talking about hyperlinks but I'm going to start out by talking about the anchor tag which is a, and you will see it right here. This is how we create a hyperlink in HTML. Something else is different about this chapter and I want to talk about this really briefly here while I've got your attention. And that is that the files in the Exercise Files folder or for this chapter, I have got them loaded up on my web server and because we are going to be talking about URLs, I would like to show you how the URLs work in the browser.

Working with hyperlinks

In this chapter we are talking about hyperlinks but I'm going to start out by talking about the anchor tag which is a, and you will see it right here. This is how we create a hyperlink in HTML. Something else is different about this chapter and I want to talk about this really briefly here while I've got your attention. And that is that the files in the Exercise Files folder or for this chapter, I have got them loaded up on my web server and because we are going to be talking about URLs, I would like to show you how the URLs work in the browser.

That way we get live URLs, real URLs, and you can actually run the examples off of the files in my server. They have been up there for years and they will continue to be up there, since the last time that I did a course of this title and this is a refresh of that course. So, I have refreshed that files and they are all still up there and they will continue to be up there. And the files are also included in the Exercise Files folders that came with this course. So, you have got it both ways and you can follow along in your text editor. And so we'll start talking about the anchor tag at this point.

So, the Anchor tag, which is spelled a, is a inline tag and you will see that it's here inline in a paragraph, we've got a paragraph tag wrapped around it, and it ends over here. So, we have got a begin tag and an end tag and we have got two attributes in this one. The first attribute is the href attribute, spelled href, and that contains the URL that you are linking to. And then I have got title attribute here also, which works just like other title attributes when you hover your mouse over the link, it will give you a little of a text tip which will say More about Bill here.

And then the content of the a tag is the text that will be used as the link and normally on a web browser it's underlined, of course, you can change that with CSS, but we'll be using it in a normal mode here so that we can see how this works so. This file is loaded up on my web server and it's at this URL here, so you can type that into your browser to follow along. Now I'm going to switch over to the browser right now, so we can see what this link looks like. So here is that page in the browser and there is the link that we are looking at and you will notice when I hover the mouse over it, it says More about Bill and if you look down at the bottom of the screen, you will see there is the URL that was loaded up in the link in the a tag.

So I'm going to go ahead and click on this link and you will see that the browser loads up my homepage and there's the URL that we clicked on. That's the URL that was in the a tag and so it loaded up this webpage which is my homepage what it looks like today. It will probably be different by the time you look at it because I change it a lot and I'll go ahead and I'll click on the Back link there in the browser and you will see that we are back at the page. Now you will notice something else here, the link has changed color, this means that I have already looked at this pages.

It's the same URL with a different attribute we'll look at that a little bit later. But you will see that the link has changed color because I have already visited that particular URL. These other links are still the other color because we haven't visited those yet and so the link changes color. That's called the visited color and when you look at the attributes in CSS, when we cover CSS you will see that the anchor tag has options for changing the attributes of visited and unvisited links and things like that. So, this is the visited color and it's the unvisited color.

So switching back to the text editor, you will see that this here is what's called a URL. URL stands Uniform Resource Locator and it's a mouthful and it doesn't really mean what it says but in any event, that's what it stands for. It's one of those old traditional Internet things that's just what it is. And so, let's take a look at the parts of a URL, so we can understand how a URL works. The first part of the URL is called the scheme and it's the part to the left of the colon and in the case of webpage URLs, that will always be http.

You will see also, sometimes if you are looking at files on your local computer, you will say file: but usually the ones that we are interested in for the purposes of XHTML and web pages we are going to say http. The next part of the URL after the two slashes is the host name and so this would be something like bw.org for my webpage or lynda.com for hers. It will often have www before it or something else, but that's the host name and that follows the rules of Internet address. It can be an IP address, it can be a DNS name, but that follows those rules and that's what goes in the host part.

And then sometimes you will see a colon and a number and that's a port number, you don't see that very often anymore. And then after all of that, you will see a slash and that's where the path goes and so if we look at this webpage here, you will see up here in the URL we have the scheme which is http and the :// and then we have the host name which bw.org. On my website I don't put the www before it. It was just a choice I made a long time ago and it's always worked for me. I don't have a port number because that's just rare to see anymore, but I do have the slash and then the path.

And so this path, misc/xhtml-links/ hyperlinks.html, that's the path to the file that has the XHTML code in it, and so that is called the file path. After the path, there can be a colon followed by parameters, you don't see that very often. There can be a question mark followed by a query that you do see often for interactive sites. That has to do with the CGI spec and how CGI parameters are passed on a URL. And often times you will see the # sign and a fragment, which takes you to a portion of the page, we'll look at those in a little bit of detail in a later lesson in this chapter.

So those are parts of the URL and that's what a URL is made of. There are actually a few other little parts that you never even see anymore and so we didn't bother to cover those, but it's a pretty complicated spec. But mostly what you see is the scheme, the host, and the path and sometimes you will see query and sometimes you will see a fragment. But for the most part that's all that you will see. So we look at this URL, we now know what these parts are, we have the scheme and we have the host name and we have the path to the file and those are the parts that we'll be concerned about for this lesson.

One other thing that I would like to show you about the anchor tag, before we move on to the next lesson, you will see we have the bw.org link twice and the other one has the target=_blank attribute and so here it is with the target=_blank attribute. What this does is it targets a blank page. When we cover frames we'll see some other uses for the target attribute, but this special word _blank, that creates a blank page for the link. So let's look at how that is used. This is the regular link that we clicked on before and that just takes us to the webpage and it loads it in exactly the same browser window, but when I click on this one and I'm in Firefox, so it will make the new window in tab.

But sometimes in some browsers, it will launch an entirely separate browser window and you will see that it's loaded up the page here in a blank Window. You see we still have the hyperlinks page loaded in the other Window and so in Firefox it does them in tabs and in other browsers, it may just open an entirely separate window. So, that's an option that you will often see. A lot of links on my page I tend to do that with because I want people to come back to this page without having to use their Back button. So, I can just close this tab and that other page is still there.

It's never gone away. So that's the target=_blank attribute and you will see that a lot in anchor tags. So that's how the anchor element works, the a element that's the parts of the URL and you have seen how the link changes on the page when it's been visited and you have seen the target=_blank attribute.

Show transcript

This video is part of

Image for XHTML and HTML Essential Training
XHTML and HTML Essential Training

59 video lessons · 80376 viewers

Bill Weinman
Author

 
Expand all | Collapse all
  1. 5m 10s
    1. Welcome
      1m 16s
    2. Using the exercise files
      1m 23s
    3. Choosing a text editor
      2m 31s
  2. 15m 46s
    1. Introducing HTML and XHTML
      2m 53s
    2. Understanding versions of HTML and XHTML
      2m 25s
    3. Exploring a simple XHTML page
      4m 47s
    4. Understanding the structure of an XHTML document
      2m 58s
    5. Understanding document containers
      54s
    6. Creating and using templates
      1m 49s
  3. 42m 4s
    1. Understanding how empty space is formatted in XHTML
      2m 42s
    2. Using paragraph tags
      2m 42s
    3. Aligning paragraphs
      2m 49s
    4. Understanding block-level and inline tags
      1m 24s
    5. Controlling line breaks and spaces
      5m 43s
    6. Formatting text with phrase element tags
      3m 28s
    7. Formatting text with font markup elements
      3m 24s
    8. Adding document structure with headings
      3m 25s
    9. Formatting quotations and quote marks
      2m 19s
    10. Preserving pre-formatted text
      1m 30s
    11. Selecting a typeface
      4m 33s
    12. Selecting a type size
      2m 11s
    13. Using ordered and unordered lists
      5m 54s
  4. 7m 48s
    1. Using inline images
      3m 17s
    2. Flowing text around an image
      2m 4s
    3. Breaking lines around an image
      2m 27s
  5. 22m 34s
    1. Working with hyperlinks
      7m 46s
    2. Using relative URLs
      3m 5s
    3. Specifying a base URL
      2m 4s
    4. Linking within a page using fragments
      4m 28s
    5. Creating image links
      5m 11s
  6. 22m 56s
    1. Introducing tables
      4m 37s
    2. Formatting tables with CSS
      8m 50s
    3. Aligning images with tables
      5m 7s
    4. Reviewing an alternative solution using CSS
      4m 22s
  7. 14m 31s
    1. Introducing frames
      7m 56s
    2. Hiding frame borders
      3m 15s
    3. Creating inline frames using iFrame
      3m 20s
  8. 20m 50s
    1. Introducing forms: part 1
      10m 37s
    2. Introducing forms: part 2
      7m 45s
    3. Using CGI with forms
      2m 28s
  9. 25m 42s
    1. Introducing CSS
      3m 11s
    2. Understanding levels of inheritance
      6m 10s
    3. Learning CSS syntax
      11m 23s
    4. Using units of measure in CSS
      4m 58s
  10. 1h 45m
    1. Comparing table layout and CSS layout
      1m 25s
    2. Exploring the finished web site
      2m 37s
    3. Building a document header
      8m 18s
    4. Placing a banner and a contact button
      8m 13s
    5. Laying out a main menu
      6m 55s
    6. Creating a layout template: main body area
      13m 31s
    7. Creating a layout template: sidebar area
      5m 17s
    8. Creating a layout template: footer content
      4m 46s
    9. Building a main home page: main body content
      11m 24s
    10. Building a main home page: sidebar content
      8m 52s
    11. Creating a page with a menu, graphics, and formatted links
      13m 26s
    12. Creating a page containing an ordered list
      6m 44s
    13. Creating a page containing video
      10m 45s
    14. Touring the finished site
      3m 45s
  11. 53s
    1. Goodbye
      53s

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
Share a link to this course

What are exercise files?

Exercise files are the same files the author uses in the course. Save time by downloading the author's files instead of setting up your own files, and learn by following along with the instructor.

Can I take this course without the exercise files?

Yes! If you decide you would like the exercise files later, you can upgrade to a premium account any time.

Become a member Download sample files See plans and pricing

Please wait... please wait ...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.


Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ.

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

Join now "Already a member? Log in

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.


Mark all as unwatched Cancel

Congratulations

You have completed XHTML and HTML Essential Training.

Return to your organization's learning portal to continue training, or close this page.


OK
Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member?

Become a member to like this course.

Join today and get unlimited access to the entire library of video courses.

Get started

Already a member?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any lynda.com page and choose Site preferencesfrom the dropdown menu.

Continue to classic layout Stay on new layout
Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

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.

Are you sure you want to delete this note?

No

Your file was successfully uploaded.

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.