Linking to Other Pages - HTML

The main advantage to the World Wide Web is the ability to link to other documents on the Web. For example, if you had a page that detailed local zoning laws, you might want to include a link to a local government site where additional information could be found. A link typically appears as underlined text and is often rendered in a different color than normal text.

For example, a link might appear in a browser as follows:

More information can be found here.

The word here is linked to the other document—when the user clicks the word, the user’s browser displays the specified page. Create links by using the anchor tag, <a>. At its simplest level, this tag takes one argument—the page to link to—and surrounds the text to be linked. The preceding example could be created with the following code:

More information can be found<a href=“”>here</a>

The href, or Hypertext REFerence attribute of the anchor tag, specifies the protocol and destination of the link. The example specifies http:// because the destination is a Web page to be delivered via the HTTP protocol. Other protocols (such as ftp:// or mailto:) can also be used where appropriate.

Additional attributes can be used with the anchor tag to specify such things as where the new document should be opened (for example, in a new browser window), the relationship between the documents, and the character set used in the linked document.

You can also use a variant of the anchor tag to mark specific places in the current document. A link can then be placed elsewhere in the document that can take the user to the specific place. For example, consider this HTML code:

For more information see <a href=“#Chapt2”>Chapter </a> . . . More HTML . . .<a name=“Chapt”>Chapter </a>

In this example, the user can click the Chapter 2 link to move to the location of the Chapter anchor. Note that the href link must include the hash symbol (#), which specifies that the link is an anchor instead of a separate page.

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

HTML Topics