freeCodeCamp/guide/english/html/tutorials/how-to-use-links/index.md

1.3 KiB

title
How to Use Links

Links are found in many webpages and its purpose is to allow users to visit other webpages.


In HTML, you can use the <a> tag to create a hyperlink.

<a href="url">link text</a>

The href attribute is very important, as it defines what the destination address is.
The link text is the actual visable text.


For example, if you wanted something to link to the freeCodeCamp website, you could type:

<a href="https://www.freecodecamp.org/">freeCodeCamp</a>

When run, this will display the text "freeCodeCamp", but it links to the website "https://www.freecodecamp.org". Clicking on the text will send you to the specified address. Neat!

Links don't need to only be text. You can add a link to an image as well!

<a href="https://www.freecodecamp.org"
   <img src="freecodecamp.png" alt = "freeCodeCamp's logo">
</a>

What we do here is we put an tag inside of an tag. This allows us to click the image to go to the link, which is https://www.freecodecamp.org. Double neato!

More Information: