Workshop


Congratulations, you learned a lot today! 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 today's exercises, you'll take the list of items you created yesterday and link them to other pages.

Q&A

Q

My links aren't being highlighted in blue or purple at all. They're still just plain text.

A

Is the filename in a name attribute rather than in an href? Did you remember to close the quotation marks around the filename to which you're linking? Both of these errors can prevent links from showing up as links.

Q

I put a URL into a link, and it shows up as highlighted in my browser, but when I click it, the browser says "unable to access page." If it can't find the page, why did it highlight the text?

A

The browser highlights text within a link tag whether or not the link is valid. In fact, you don't even need to be online for links to show up as highlighted links, although you can't get to them. The only way you can tell whether a link is valid is to select it and try to view the page to which the link points.

As to why the browser couldn't find the page you linked tomake sure that you're connected to the network and that you entered the URL into the link correctly. Also verify that you have both opening and closing quotation marks around the filename, and that those quotation marks are straight quotes. If your browser prints link destinations in the status bar when you move the mouse cursor over a link, watch that status bar and see whether the URL that appears is actually the URL you want.

Finally, try opening the URL directly in your browser and see whether that solution works. If directly opening the link doesn't work either, there might be several reasons why. The following are two common possibilities:

  • The server is overloaded or is not on the Internet.

    Machines go down, as do network connections. If a particular URL doesn't work for you, perhaps something is wrong with the machine or the network. Or maybe the site is popular, and too many people are trying to access it at once. Try again later. If you know the people who run the server, you can try sending them electronic mail or calling them.

  • The URL itself is bad.

    Sometimes URLs become invalid. Because a URL is a form of absolute pathname, if the file to which it refers moves around, or if a machine or directory name gets changed, the URL won't be valid anymore. Try contacting the person or site you got the URL from in the first place. See whether that person has a more recent link.

Q

Can I put any URL in a link?

A

You bet. If you can get to a URL using your browser, you can put that URL in a link. Note, however, that some browsers support URLs that others don't. For example, Lynx is really good with mailto URLs (URLs that enable you to send electronic mail to a person's email address). When you select a mailto URL in Lynx, it prompts you for a subject and the body of the message. When you're done, it sends the mail.

Q

Can I use images as links?

A

Yup, in more ways than one, actually. You'll learn how to use images as links and define multiple links within one image using image maps in Lesson 7, "Adding Images, Color, and Backgrounds."

Q

My links aren't pointing to my anchors. When I follow a link, I'm always dropped at the top of the page rather than at the anchor. What's going on here?

A

Are you specifying the anchor name in the link after the hash sign the same way that it appears in the anchor itself, with all the uppercase and lowercase letters identical? Anchors are case sensitive, so if your browser can't find an anchor name with an exact match, the browser might try to select something else in the page that's closer. This is dependent on browser behavior, of course, but if your links and anchors aren't working, the problem usually is that your anchor names and your anchors don't match. Also, remember that anchor names don't contain hash signsonly the links to them do.

Q

Is there any way to indicate a subject in a mailto URL?

A

If you include ?subject=Your%20subject in the mailto URL, it will work with most email clients. Here's what the whole link looks like:

<a href="mailto:someone@example.com?subject=Your%20subject">Send email</a>


Quiz

1.

What two things do you need to create a link in HTML?

2.

What's a relative pathname? Why is it advantageous to use them?

3.

What's an absolute pathname?

4.

What's an anchor, and what is it used for?

5.

Besides HTTP (web page) URLs, what other kinds are there?

Quiz Answers

1.

To create a link in HTML, you need the name or URL of the file or page to which you want to link, and the text that your readers can select to follow the link.

2.

A relative pathname points to a file, based on the location that's relative to the current file. Relative pathnames are portable, meaning that if you move your files elsewhere on a disk or rename a directory, the links require little or no modification.

3.

An absolute pathname points to a page by starting at the top level of a directory hierarchy and working downward through all intervening directories to reach the file.

4.

An anchor marks a place that you can link to inside a web document. A link on the same page or on another page can then jump to that specific location instead of the top of the page.

5.

Other types of URLs are FTP URLs (which point to files on FTP servers); file URLs (which point to a file contained on a local disk); mailto URLs (which are used to send electronic mail); and Usenet URLs (which point to newsgroups or specific news articles in a newsgroup).

Exercises

1.

Remember the list of topics that you created yesterday in the first exercise? Create a link to the page you created in yesterday's second exercise (the page that described one of the topics in more detail).

2.

Now, open the page that you created in yesterday's second exercise, and create a link back to the first page. Also, find some pages on the World Wide Web that discuss the same topic and create links to those pages as well. Good luck!




Sams Teach Yourself Web Publishing with HTML and CSS in One Hour a Day
Sams Teach Yourself Web Publishing with HTML and CSS in One Hour a Day (5th Edition)
ISBN: 0672328860
EAN: 2147483647
Year: 2007
Pages: 305

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net