Skip to Content
Learning Web Design, 5th Edition
book

Learning Web Design, 5th Edition

by Jennifer Robbins
May 2018
Beginner content levelBeginner
808 pages
25h 3m
English
O'Reilly Media, Inc.
Content preview from Learning Web Design, 5th Edition

6. Adding Links

6

Adding Links

In this Chapter

Linking to external pages

Linking to documents on your own server

Linking to a specific point in a page

Targeting new windows

If you’re creating a page for the web, chances are you’ll want to link to other web pages and resources, whether on your own site or someone else’s. Linking, after all, is what the web is all about. In this chapter, we’ll look at the markup that makes links work—links to other sites, to your own site, and within a page. There is one element that makes linking possible: the anchor (a).

<a>…</a>

Anchor element (hypertext link)

To make a selection of text a link, simply wrap it in opening and closing <a>...</a> tags and use the href attribute to provide the URL of the target page. The content of the anchor element becomes the hypertext link. Here is an example that creates a link to the O’Reilly Media site:

<a href="http://www.oreilly.com">Go to the O'Reilly Media site</a>

To make an image a link, simply put the img element in the anchor element:

<a href="http://www.oreilly.com"><img src="tarsierlogo.gif" alt="O'Reilly Media site"></a>

By the way, you can put any HTML content element in an anchor to make it a link, not just images.

Nearly all graphical browsers display linked text as blue and underlined by default. Some older browsers put a blue border around linked images, but most current ones do not. Visited links generally display in purple. Users can change these colors in their browser preferences, ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Learning Web Design, 4th Edition

Learning Web Design, 4th Edition

Jennifer Robbins

Publisher Resources

ISBN: 9781491960196Errata Page