Skip to content

Try our new Crash Courses!

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

Link to an external website – HTML


Note: the external link will not work in the CodePen below, but it will work in your own index.html file.


To create a link to another website, use the anchor element with the href attribute.

<a href="">External link</a>

To see what this element looks like in the browser, click the link in the Demo section below.


The process of creating a link to an external website is similar to creating a link to one of your own pages. The difference is that links to external websites should use absolute URLs (meaning they should include the http:// or https:// protocols with the URL and the domain name).

Here is a version of the external link demo hosted on GitHub Pages that works in the browser.


Recreate the embedded CodePen demo by typing out the HTML code. Test the link to make sure it works.

Then try changing the URL to a different site.


The Anchor element on MDN

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