Opening Links in a New Window

You may have noticed that links don't always open in the same window. This is often done when we want to direct users somewhere but expect them to return.

We achieve this by adding another attribute, target, with the value _blank.

<a href="https://en.wikipedia.org/" target="_blank">Link to Wikipedia</a>

So, if we want the link to open in a new window, our link will have 2 attributes:

  • href with the value of the link.
  • target with the value _blank.

The order of the attributes doesn't matter.

Instructions

Add an attribute target with the value _blank to the a element you created in last exercise.

Start programming for free

By signing up, you agree to the Terms of Service and Privacy Policy.

Or sign up with:

3/10