Internal and External Links in HTML

Learn to create links to other websites and to sections within the same page using different `href` values.

Internal vs. External Links

HTML links can point to other websites or to different sections of the very same page. Let's learn the difference between external and internal links!

External Links

External links use a complete, absolute URL in the href attribute to direct users to a different website. It's best practice to have these open in a new tab using target="_blank".

Internal Links (Anchors)

Internal links use a hash (`#`) followed by the `id` of an element on the same page. For example, <a href="#contact"> will jump to the element with <div id="contact">.

Practice Zone


Interactive Test 1: Drag & Drop

Arrastra en el orden correspondiente.


Arrastra las opciones:

<a
href="#section1">
<div id='section1'>

Completa el código:

______
______
______

Interactive Test 2: Fill in the Blanks

Rellena los huecos en cada casilla.

<a >Go to Section 1</a>
<div >Content</div>

Practice Example: Code Editor

Create an external link to `https://www.google.com` and an internal link to a section with the id `contact`.

* Write the code below. Correct characters will be shown in green and incorrect ones in red.

<a href="https://www.google.com">Visit Google</a> <a href="#contact">Go to Contact Section</a> <div id="contact"> </div>

Knowledge Check

What character must an internal link's href attribute start with?