Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

HTML

How do i open a page in a differwnt window

I am making a social media link on my website and I can't remember how to make the link open the page in a different window. I have looked it up but I have not gotten a straight answer. Pople always say copy this and it will work, I would like to know how to make it my self.

Ermin Bicakcic
Ermin Bicakcic
5,144 Points

Hi, it is fairly straight forward: <a href="https://linktotargetyouwanttogo" target="_blank">link text</a> target="_blank" is what makes it open in a new window.

1 Answer

Jamie Reardon
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Jamie Reardon
Treehouse Project Reviewer

There is an attribute that you can add to the anchor element (which is used to create a link) that enables the link to open in a new tab. This attribute is called target and the value needed for this action is _blank.

An example link would look like this:

<a href="http://mysite.com" target="_blank">Text For Link</a>

If you scroll down the page on this link you will find more information and examples of the target attribute.