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

JavaScript Treehouse Club: JavaScript Car Sounds External Style Sheets

What is the use of the href= in the html coding sheet?

I have been seeing this code in the workspace but I don't understand what its for. I know its important. Need help!

href is a tag we use mainly to highlight a part of code. and to redirect using the link to concerned page..for example <a href="www.google.com">Google Search</a> It displays Google Search in blue color when you tap on that it redirects you to www.google.com

2 Answers

huckleberry
huckleberry
14,636 Points

Heya Cristian!

href is an attribute that goes within an anchor tag. An attribute is just some extra information that gets applied to a certain element within your HTML. In the case of your anchor tags (the <a> tags that display links on a web page) the href attribute is what contains the url of the link. href stands for hypertext reference

href="" is the complete syntax. Inside of the quotes is where you place the url. Once the link is shown on the web page, clicking it will bring you to whatever url you placed inside of the quotes after the href attribute.

<a href="http://google.com">Click here to search Google!</a>

The above code would place a link on your web page that says Click here to search Google! and clicking that link would bring you to google.com because that's the url you put inside of the href attribute.

Cheers,

Huck - :sunglasses:

jason chan
jason chan
31,009 Points

It's basically href is a route to different webpage. So think of it as button to go to a different webpage. I hope that helps. You see them all the time.

It's that text with underline that redirects you to different page.