Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

CSS

Nikki Turrisi
Nikki Turrisi
15,095 Points

Why is it in CSS that in order to identify certain properties, the syntax is different?

for example:

if I wanted to select the wrapper element, couldn't I just write:

wrapper {}

instead of ...

(hashtag) wrapper {}

--why is there a # in front of some, and not in front of others in the lesson?

2 Answers

{hashtag} is for id's
. is for classes
and nothing is for html elements.

To ellaborate the '#' and '.' are used for CSS specificity purposes. When you begin to build more complex web pages then you'll start using classes to chunk changes together rather than make the same change multiple times. for example.

#customer .tabContainer div {
   font: Arial, #000 solid;
   padding: 10px
}

You know you are pinpointing that part of the code because of the classes, id and tag. Then if want to be more specific then you would add either another class or id.