HTML and CSS Reference
page was retrieved! If you use file URLs as links in your page, and someone from else-
where on the Internet encounters your page and tries to follow those links, that person's
browser will attempt to find the file on her local disk (and generally will fail). Also,
because file URLs use the absolute pathname to the file, if you use file URLs in your
page, you can't move that page elsewhere on the system or to any other system.
If your intention is to refer to files that are on the same file system or directory as the
current page, use relative pathnames rather than file URLs. With relative pathnames for
local files and other URLs for remote files, you shouldn't need to use a file URL at all.
In this lesson, you learned all about links. Links turn the Web from a collection of unre-
lated pages into an enormous, interrelated information system. (There are those big
To create links, you use the <a>...</a> tag pair, called the link or anchor tag. The
anchor tag has attributes for creating links (the href attribute) and anchor names (the
When linking pages that are all stored on the local disk, you can specify their pathnames
in the href attribute as relative or absolute paths. For local links, relative pathnames are
preferred because they enable you to move local pages more easily to another directory
or to another system. If you use absolute pathnames, your links will break if you change
anything in the hard-coded path.
If you want to link to a page on the Web (a remote page), the value of the href attribute
is the URL of that page. You can easily copy the URL of the page you want to link. Just
go to that page by using your favorite web browser, and then copy and paste the URL
from your browser into the appropriate place in your link tag.
To create links to specific parts of a page, set an anchor at the point you want to link to,
use the <a>...</a> tag as you would with a link, but rather than the href attribute, you
use the name attribute to name the anchor. You then can link directly to that anchor name
by using the name of the page, a hash sign ( # ), and the anchor name.
Finally, URLs ( uniform resource locators ) are used to point to pages, files, and other
information on the Internet. Depending on the type of information, URLs can contain
several parts, but most contain a protocol type and location or address. URLs can be used
to point to many kinds of information but are most commonly used to point to web pages
( http ), FTP directories or files ( ftp ), or electronic mail addresses ( mailto ).