What’s in a Link? - HTML

Web links have two basic components, the link and the target.

  • The link is the text in the main document that refers to another document.
  • The target is the document (or particular location in the document) to which the link leads.

For example, suppose a site on the Web reviews software. Each review includes a link to the manufacturer’s Web site. Such an arrangement would resemble the diagram. The link has two components: a descriptor and a reference to the target. The target is a document that can be delivered via the Internet. In the preceding example, the review might list the manufacturer’s name as the descriptor and the actual Web URL would be the reference. Both are specified in the anchor tag (<a>), as follows:

The relationship of documents on the Web via links—the user clicks the link in the review document to reach the xyz Inc. home page.

The relationship of documents on the Web via links
The target reference is specified via the href attribute, and the descriptor appears between the start and end anchor tags. For example, if the manufacturer is Acme Computers and its Web site is acme.example.com, the anchor tag would resemble the following:

If you don’t give the name of a document in the link, the Web server (in this case, www.example.com) will send the defined top-level document (known as an index document)—typically, this document is named index.html or home.html. If such a document doesn’t exist or one has not been defined for the server, an error will be returned to the client browser. The text “Acme Computer’s Web Site” would be highlighted in the document to show it is a link.

The default highlight for a link is a different color font and underlined, though you will see how to change the highlight later in this chapter.

Note:According to the “strict” HTML standard, anchor links need to be placed within block elements (headings, paragraphs, and so on). As mentioned in the introduction to this chapter, you can link to other things besides HTTP documents. All you need is the URL of the item you wish to link to, and the protocol necessary to reach the item. For example, if you wanted to link to a document on an FTP site, you could use an anchor tag similar to the following:

Note that the protocol is specified (ftp: instead of http:), and the server name is specified), as is the path and filename (/pub and example .zip). A similar method. Clicking such a link will generally spawn the user’s e-mail client ready to send an e-mail to the address specified.

Note: The rest of this chapter concentrates on linking to other HTML documents on the Web. However, all the concepts addressed apply when linking to other content types.

All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

HTML Topics