What other things can HTML links be set to?


#1

Question

In the context of this exercise, what other things can HTML links be set to?

Answer

Links in HTML can be set to several different things.

As covered in the exercise, links are mainly used to connect a webpage with other webpages. This can be done by setting the link to go to the URL of a specified site, like

<a href="www.codecademy.com">Codecademy</a>

Links can also be set to link to documents and files, such as text, audio, video and image files. For example,

<a href="www.example.com/image.svg">Image</a>

HTML links can also be set to a specific part of the same webpage, such as a section header. This can be done using the id attribute of an element, and using that id value preceded by a # as the value of the href attribute. For example, in the following code, clicking the “Main” text would make the browser jump to the section with the corresponding id value of "main".

<a href="#main">Main</a>

<div id="main">
</div>