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 CSS: Cascading Style Sheets Take a Mobile-First Approach

Justin Benton
Justin Benton
4,765 Points

Why Hashtag in CSS Selector??

When typing the CSS for the wrapper div selector and the logo header selector in these exercises, the video says to use a hashtag at the beginning (#wrapper, for example). Why? Is the hashtag short for ID (as these are the IDs we assigned in html)? Sorry, maybe a random question; I just have one of those brains that learns better when it understands why certain things need to be done a certain way. Thanks!

Devin Scheu
Devin Scheu
66,191 Points

'#' is used to selected a certain element you gave an ID to, it's mostly used because if a selection has multiple of the target such as two divs, you can select each on individual one directly. The # is used mostly for convenience , it's a quick and easy way to tell if something is an ID.

1 Answer

nulled
nulled
1,890 Points

The hashtag '#' is an id selector used to target a single specific element with a unique id, while a period '.' is a class selector used to target multiple elements with a particular class.

Put into play, here is how it would look:

<div id="red">This will be red.</div>
<div class="blue">This will be blue.</div>
#red {
    color: red;
}

.blue {
    color: blue;
}