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 trialMadeline Yao
Full Stack JavaScript Techdegree Student 9,611 Pointsone tag with two classes?
When I saw the code "<p class='tag location'> My home is Salem, Oregon</p> " in the workspace, I wonder why the code can have two classes and what those two classes do.
2 Answers
Justin Cantley
18,068 PointsA tag has no limit to the amount of classes that it can have. Classes can be used to style an element in a specific way and that element may need to take on the style of several different classes. If an element does have more than 1 class it should always be contained in the same class attribute separated by a space between each class name. Ids on the other hand are different. An element can only have 1 ID.
Prashant Kumar
1,992 PointsActually, I'm just start learning and I think using 2 classes makes the work easy. Like in this example project first tag class was class= ''tag name" and the other is class= "tag location". So, once we decide the CSS styling script of class= "tag" than all the class with the name "tag" will have occupied the same styling property. Am I right?
Justin Cantley
18,068 PointsThat's correct. For example if it looked something like this:
.tag {
border: solid black 1px;
}
then every element with the class tag would have a solid, black, 1 pixel border around it.