Lesson 04 - Adding Links
Lesson 04 - Adding Links
Adding Links
Objectives
• Making links to external webpages
• Making relative links to documents on your
own server
• Linking to a specific point in a page
• Adding "mailto“ link
• Targeting new windows
Anchor <a>
• element that makes linking possible is the
anchor tag (<a>…</a>).
• 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.
• To make an image a link, simply put the img
element in the anchor element:
The href Attribute
• Absolute URLs provide the full URL for the
document, including the protocol (http://), the
domain name, and the pathname as
necessary.
• You need to use an absolute URL when
pointing to a document out on the Web (i.e.,
not on your own server).
example: href="http://www.oreilly.com/"
• Relative URLs describe the pathname to a
file relative to the current document. Relative
URLs can be used when you are linking to
another document on your own site (i.e., on
the same server). It doesn’t require the
protocol or domain name—just the
pathname.
example: href="recipes/index.html"
Linking Within Your Own Site
Linking within a directory
• A link to just the filename indicates the linked
file is in the same directory as the current
document.
Linking to a lower directory