Start your free trial now, and begin learning software, business and creative skills—anytime, anywhere—with video instruction from recognized industry experts.

Start Your Free Trial Now

Creating image links


From:

XHTML and HTML Essential Training

with Bill Weinman

Video: Creating image links

Remember that an image is an inline element and that means that it flows as part of the text and that also means that we get to use images for links. You'll see this a lot, you see an image in a web page and you click on that image and it takes you some place else and everybody is happy. They can use their images as links as it should be. And so, here's an example of how that's done. This is an XHTML file and here's a paragraph, and in that paragraph we have "This paragraph has an image that is also a link." And in fact, you see it down here in the browser.
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 5s
    1. Understanding how empty space is formatted in XHTML
      2m 42s
    2. Using paragraph tags
      2m 43s
    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 50s
    1. Using inline images
      3m 17s
    2. Flowing text around an image
      2m 5s
    3. Breaking lines around an image
      2m 28s
  5. 22m 35s
    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 12s
  6. 22m 47s
    1. Introducing tables
      4m 37s
    2. Formatting tables with CSS
      8m 50s
    3. Aligning images with tables
      4m 59s
    4. Reviewing an alternative solution using CSS
      4m 21s
  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 46m
    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 14s
    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 25s
    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

please wait ...
Watch the Online Video Course XHTML and HTML Essential Training
4h 44m Beginner Jul 28, 2009

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.

Topics include:
  • Understanding the structure of an HTML or XHTML document
  • Creating and using templates
  • Controlling white space and line breaks
  • Making effective use of tables and frames
  • Flowing text around an image
  • Formatting tables with CSS
  • Creating web pages that work properly across platforms and devices
  • Reviewing a case study of a complete web site
Subjects:
Developer Web
Software:
HTML XHTML
Author:
Bill Weinman

Creating image links

Remember that an image is an inline element and that means that it flows as part of the text and that also means that we get to use images for links. You'll see this a lot, you see an image in a web page and you click on that image and it takes you some place else and everybody is happy. They can use their images as links as it should be. And so, here's an example of how that's done. This is an XHTML file and here's a paragraph, and in that paragraph we have "This paragraph has an image that is also a link." And in fact, you see it down here in the browser.

This paragraph has an image that is also a link. And there is the image and you can see it's got this pretty blue box around it, which ought to tell you that that's a link. You see the browser changes when I move it over that and when I click on it, it will take us to lynda.com because here's the anchor tag, a href=http://www.lynda.com/. So, I click on that and there is the lynda. com web page and I'll press the Back button. It will take us back here. We'll see that the pretty blue box is now purple because that's our visited link color.

And so that's how an image works as link. Well, there are couple things about this that I would like to change. One is the pretty blue box. I'm not actually very fond of it. So, I'd like to get rid of that. How you do that is with the border attribute in the XHTML. So, in the image tag, I'm going to type an attribute here, border=0 and that gets rid of the box. Go ahead and save it and reload in the browser and the box is gone. That's actually much more attractive, I like that a lot better and so you see when I hover my mouse over it, it's obvious that it's a link and I click on it and it takes me to lynda.com and I click the Back button and I'm back here and everything is good.

Except, you'll notice a little dotted line around it and frankly, there is not a way to get rid of that in the Firefox browser. But you'll notice that it extends beyond the image. The image actually ends about there and the dotted line is actually beyond it and enclosing the space after the image. In fact, if I click outside of the image, we'll get rid of the dotted box but you see that my cursor actually starts changing during that space. That space after the image is part of a link and that's not really what I want. On the other side, it doesn't do that.

So this is just a quirk of the Firefox browser. Actually all the browsers have some kind of a quirk in this same area and I can get rid of all of those quirks with the same technique. The reason that space is part of the link is I actually told it that I wanted that space to be part of the link because after my image tag I've a new line and a couple of spaces here and then the end of the anchor tag. You see and we remember that the browser will take all of that white space including the new line and the spaces and folded into one space which is exactly what it's done here, so it looks all nice and spaced out in the sentence.

But that's part of the link because I've included that in the A container. So the way to get rid of it is to take the space out of the container to abut the image tag right up against the A tag. So I'll do that at the beginning, because even though isn't creating that as part of the link, in other browsers do and then over here at the end, I'll go ahead and I'll close up that space as well. And so now our image tag is right up against the anchor tag.

So the end of the begin tag, the anchor tag, there is no space between that at the beginning of the image tag and then at the end of the image tag here, there is no space between that and the end tag for the anchor element. So, when I save this and reload in the browser you'll see that you no longer have this problem. The space is not part of the link anymore and if I click on the link, you'll see that dotted box is now tight around the image and it's not enclosing the space after it anymore or the space before it.

Now the only problem with this is that this makes it necessarily longer and you know how I am. I like for things to look good in my editor as well as on the page. So I'm going to show you how this can be pretty in the editor and on the page. You notice if I break the line here, and I'll indent it a little bit, that space is inside of the anchor begin tag. So that does not actually get rendered by the browser. That's part of the rules. Browser is not allowed to render anything inside of those angle brackets. And so I can do the same thing over here and I'll actually indent that like that and so the end of the A tag is over here right up against the image and the end of the image tag is over here right up against the end tag for the A.

And so those spaces and those new lines while they are up on the screen in the editor and they help to make that pretty, they are not going to be rendered by the browser. So I'll go ahead and I'll save this and I'll reload over here and we'll see that our problem is still not a problem anymore. Those spaces are still not part of the link anymore. I can click on this and that full square is tight around the image. So in summary, this is how you create links out of images and this is how you make them work well in the editor and also on the page.

Find answers to the most frequently asked questions about XHTML and HTML Essential Training .


Expand all | Collapse all
please wait ...
Q: In this title, the instructor uses tables to create a website design. Is there a way to create this same layout with CSS?
A: This course will be updated to include CSS-based layout techniques within
the next few months. In the meantime, please see Bill's <a href="
http://www.lynda.com/home/DisplayCourse.aspx?lpk2=52341">CSS for
Developers</a> title for more information on coding with CSS.
Q: In the "Understanding the structure of an XHTML document" movie in Chapter 1, where does the "Roses are red," etc, text come from? I don't see it in the code.
A: Notice the <frame src="??"> tags. These reference other .html files that contain the content of the various frames. Details about how frames work can be found in Chapter 6 of the course.
Q: In this title, the instructor uses tables to create a website design. Is there a way to create this same layout with CSS?
A: This course will be updated to include CSS-based layout techniques later in 2012. In the meantime, please see Bill's CSS for Developers title for more information on coding with CSS.
 
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

* Estimated file size

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

Upgrade to View Courses Offline

login

With our new Desktop App, Annual Premium Members can download courses for Internet-free viewing.

Upgrade Now

After upgrading, download Desktop App Here.

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 ?

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:

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.

Learn more, save more. Upgrade today!

Get our Annual Premium Membership at our best savings yet.

Upgrade to our Annual Premium Membership today and get even more value from your lynda.com subscription:

“In a way, I feel like you are rooting for me. Like you are really invested in my experience, and want me to get as much out of these courses as possible this is the best place to start on your journey to learning new material.”— Nadine H.

Start your FREE 10-day trial

Begin learning software, business, and creative skills—anytime,
anywhere—with video instruction from recognized industry experts.
lynda.com provides
Unlimited access to over 4,000 courses—more than 100,000 video tutorials
Expert-led instruction
On-the-go learning. Watch from your computer, tablet, or mobile device. Switch back and forth as you choose.
Start Your FREE Trial Now
 

A trusted source for knowledge.

 

We provide training to more than 4 million people, and our members tell us that lynda.com helps them stay ahead of software updates, pick up brand-new skills, switch careers, land promotions, and explore new hobbies. What can we help you do?

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.