Skip to content

Try our new Crash Courses!

Buy one of our new Crash Courses, now hosted on Podia.

Link to another page on your website – HTML

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.

References

The Anchor element on MDN

Lesson tags: Open Lesson
Back to: HTML Reference > HTML Links