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

CSS CSS Selectors Selectors - Beyond the Basics Attribute Selectors

Kim Gee
Kim Gee
3,841 Points

[class] vs [id]

As I understand it. In the video you taught 3 ways to handle an id attribute selector.

1.  div[id="container"] { 
max-width: 500px;
margin: auto;   
}
2.  input[placeholder] { 
    background: #fdfee6; 
 }
3.   input[type="email"] { 
    background: #fdfee6; 
 }
// In the video you taught 1 way to handle the class attribute selector. My question is can the [class] be handled the same way as the [id] ? 
1.  [class="form-contact"] { 
padding: 20px 24px;
background:#f4f7f8;
}

1 Answer

Jonathan Grieve
MOD
Jonathan Grieve
Treehouse Moderator 91,252 Points

Yes I believe can. :). Class is an attribute to an element in the same way as id is so you should be able to select elements the same way. :-)