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 Introduction to HTML and CSS (2016) HTML: The Structural Foundation of Web Pages and Applications Anchor Tags

Shirley Hasbani
Shirley Hasbani
487 Points

What does the # sign mean or do? Why don't we use it before a link?

I know that #top or #bottom will take me to the top or bottom lol but what else could I use it for? What does it do generally exactly?

jakub kicinski
jakub kicinski
6,572 Points

The # sign is generally used as a place holder in the href attribute until you replace it with an actual link.

1 Answer

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! The # is used both in HTML and CSS to identify an "id". Because a webpage can only have one id named the same thing we can use it to reference something in particular. For example, you may not have two <div> elements with the id "main-content". Only one element may have that id at a time.

That being said, the #top and #bottom are generally recognized by default by most browsers (for the time being). That could change with upcoming versions of HTML. But the idea here is that you can divide a webpage into different sections and link to those sections within the same page.

Imagine for a moment that you had several divs and you wanted the navigation at the top of your page to take you to that section of the page instead of an entirely different page. This brings up a different use of the <a> tag than you may have seen before.

But you could have something like this:

<!-- this is the "anchor" and sets the point to go to when the href asks for "past-projects" -->
<a name="past-projects"></a> 


<!-- this is the link that that will cause it to jump to the section where the above anchor appears -->
Click <a href="#past-projects">here</a> to view my past projects.

Hope this helps! :sparkles:

Bob Marley
Bob Marley
1,106 Points

That's a very helpful explanation, Jennifer. Thank you.