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 HTML Forms Fieldsets and Labels

Fred Sites
Fred Sites
11,151 Points

Why don't you need a # when linking the label for id=username?

Throughout the course we've seen a # is need to link to an id. In this video (fieldsets and labels) we connect a label to an input. Nick is clear that we need to give the input an ID attribute but we do not need a # to have the created label attach to that input.

3 Answers

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

The # in front of an id is used within css. In the case your talking about, you are referencing the id within the html, so using a # would do nothing.

You use '#' in the CSS file for id. Just like you use '.' for classes in the CSS file. These are not used in the html file.

The # and . are called selectors and they tell whatever is using them how to interpret the text that follows. In CSS and Javascript it lets the browser know to look for one ID in the DOM #coolid or multiple classes .coolclasses. The only time you are using them is when you are working within a technology the is referencing them, not defining them.