Sams Teach Yourself HTML, CSS & JavaScript Web Publishing in One Hour a Day

(singke) #1
ptg16476052

Workshop 117

6


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.


Summary


In this lesson, you learned about links. Links turn the Web from a collection of unrelated
pages into an enormous, interrelated information system.


To create links, you use the ... tag pair, called the link or anchor tag. The
anchor tag has attributes for creating links (the href attribute) and anchor names (the
name attribute).


When linking pages that are 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
with the id attribute on an element at that part of the page. You then can link directly to
that ID by using the name of the page, a hash sign (#), and the ID.


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).


Workshop


Congratulations, you learned a lot in this lesson! Now it’s time for the workshop. Many
questions about links appear here. The quiz focuses on other items that are important for
you to remember, followed by the quiz answers. In the following exercises, you’ll take
the list of items you created in Lesson 5, “Organizing Information with Lists,” and link
them to other pages.

Free download pdf