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 Foundations Advanced Selectors Substring Matching Attribute Selectors

Péter Gacsályi
Péter Gacsályi
9,242 Points

Could you please mention 1-2 real life example for using substring matching attribute selectors?

CSS

1 Answer

kevin revill
kevin revill
7,533 Points

actually had this in my day job the other day. we use a 3rd party to provide content. they will hold our style sheet. but all the ids on all the elements are randomly generated for each user each beginning with a prefix. Its weird and its out of my control.

However, i can match the div structure and the prefix's they use to target the right elements.

I have seen coders too add class names which increment ie class="post234". Again matching can target these, but before you say it. I agree that adding a secondary class would resolve the issue ;) Just sometimes as in my first example you don't get the control of what's generated but you do have to style it any ways.