Summary
To create a link to another page on your website, use the anchor element with the href
attribute.
<a href="page.html">Link text</a>
Details
Examples
If the file you’re linking to is in the same folder as your current HTML file, just use the file name with the href
attribute. Here’s an example:
<a href="about.html">Link to about page</a>
If the file you’re linking to is in a subfolder, make sure you include the folder name in the href
attribute. Here’s an example:
<a href="folder/about.html">Link to About page in different folder</a>
If the file you’re linking to i nested inside several folders, make sure you include all of the folder names in the href
attribute, like this:
<a href="first-folder/second-folder/about.html">Link to About page in different folder</a>
If the file you’re linking to is in a higher folder, use two dots to move up a folder. Here’s an example:
<a href="../index.html">Link back to home page</a>
Exercises
Add a link to your index.html file that goes to the about.html page.
Using your text editor, try creating a second HTML page and then create a link to it from your first HTML page. Then try creating a third HTML page in a subfolder and create a link to it from your first HTML page.
References
The Anchor element on MDN