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 to Make a Website Creating HTML Content Include External CSS

what is href attribute as in <a href=

Can you explain what the "href" in <a href=index.html"></a> means? just looking for some clarification on this. I think it is the code to add a link between 2 html files, is this correct?

Yonatan Schultz
Yonatan Schultz
12,045 Points

<a> is an anchor tag in html. href within that anchor lets that anchor know where it will be referencing. This is typically used for links. For instance,

<a href="http://google.com">Google</a>

Will display a link to google.com

3 Answers

Liam Maclachlan
Liam Maclachlan
22,805 Points

an anchor tag Href specifies the destination of a link.

This could be an ID on a page or a link to another page :)

thank you!!

Liam Maclachlan
Liam Maclachlan
22,805 Points

No problem. Glad I could clear it up :)

Sam Donald
Sam Donald
36,305 Points

If you'r using the link to direct visitors to an image, video, article etc... on another site then a good idea would be to give your anchor tag a blank target, like this.

<a target="_blank" href="http://somedomain.com">some words</a>

This will make the liked page (the href attribute) open in another tab. This is good for external site links as it allows your site visitors to remain on your site while still delivering the content they were after.