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 trialRobin Malhotra
14,883 PointsWeird CSS Syntax
Could someone explain the weird CSS Selectors used here:
.grid-container > [class^="grid-"]:first-child
.grid-container > [class^="grid-"]
etc?
1 Answer
Jonathan Grieve
Treehouse Moderator 91,253 PointsThese are known as attribute selectors. They select elements based on what in a HTML attribute. In this case, it's attaching to a class attribute that starts with the text grid.
Here's the latest stuff by CSS tricks on Attribute Selectors :-) https://css-tricks.com/almanac/selectors/a/attribute/
rdaniels
27,258 Pointsrdaniels
27,258 Pointsthe part in the square brackets are saying "pick anything in the HTML page with the class that starts with "grid-". The top one picks out any code with the class that starts with "grid-" and then applies "something" to the first-child of that class.