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 trialTyrone Roberts
1,182 PointsWhy does class="tag name"... in CSS shows .tag but instead of .name?
.tag {
background-color: #efefef;
color: purple;
padding: 10px;
border-radius: 5px;
display: table;
margin: 10px auto;
}
.location {
background-color: #222;
color: white;
}
class="tag location" shows as .location in CSS. Did I miss something? I'm a bit confused.
2 Answers
Cheri Young
442 Pointsclass="tag location" is actually showing you 2 different classes. The space in the middle tells us the element has 2 separate classes. The first class is called "tag" and the second class is called "location" An html element can have more than one class. When a class is being styled in CSS it is identified by the name of the class with a period in front of it. ex: class="tag" shows is CSS as .tag { background-color: #efefef; color: purple; padding: 10px; border-radius: 5px; display: table; margin: 10px auto; }
ex: class="location" shows in CSS as .location { background-color: #222; color: white; }
In your main question, .name is not showing in CSS because that particular tag does not have any styling added yet.
Hope this helps! :)
Tyrone Roberts
1,182 PointsFixed my issue. Correct Syntax would be class="tag-location" which would be .tag-location in CSS.
Thanks for your help!
Tyrone Roberts
1,182 PointsTyrone Roberts
1,182 PointsThanks for the response Cheri!
I get what you are saying but if change the color of .tag in CSS it changes the color of class="Tag name" once it is published. My class for .location shows in html as class="tag location" and .location in css as it should.
HTML <header> <img src="images/Testimg1.jpg" alt="Picture of Tyrone & Rachel" class="profile-image"> <h1 class="tag name">Tyrone Roberts</h1> <h2 class="tag location">My home is New York, NY</h2> </header>
CSS .tag { background-color: #efefef; color: orange; padding: 10px; border-radius: 5px; display: table; margin: 10px auto; } .location { background-color: #222; color: white; }