Linking to Another Website in HTML

When linking to a website, the link typically points to the home page (i.e., it is the URL of a website’s root directory on a Web server that is typically specified); the URL of a specific document is not usually specified. When a link points to the root directory, the Web server usually serves the document index.html by default, which is the home page. Figure 4.20 shows how this is done, and Figure 4.21 depicts the result.

Where a link is inside text, as opposed to when used in a main menu, in order to enhance accessibility, link text should be meaningful enough to convey its purpose on its own and out of context. If this is not possible, any additional description providing the context for the link should be placed close to the link (e.g., in the same sentence or paragraph), such that it is easy for users to identify without moving focus from the link. A good example and a bad example are shown in the NOTE box that follows.

CHALLENGE 4.8

Write the HTML code to display the content between the quotes in the paragraph below, linking the word “Earth” to https://en.wikipedia.org/wiki/Earth.

“The Solar System is made up of the Sun and the objects that orbit it. One of these objects is the planet known as Earth, which is where we live.”

Source: Sklar David (2016), HTML: A Gentle Introduction to the Web’s Most Popular Language, O’Reilly Media; 1st edition.

Leave a Reply

Your email address will not be published. Required fields are marked *