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 Going Further with Attribute Selectors and Pseudo-Classes Substring Matching Attribute Selectors - "Begins With" and "Ends With"

Learning coding
seal-mask
.a{fill-rule:evenodd;}techdegree
Learning coding
Front End Web Development Techdegree Student 9,937 Points

Why not change the color of the link with ul li?

I probably don't understand something, but using the begins with substring seems more complicated than just using ul li to change the color. Can someone explain this a bit more? Thanks.

ywang04
ywang04
6,762 Points

I would like to say even thought you want to use simpler selectors to change color of the link.

In this case, it should be ul a instead of ul li. :)

1 Answer

Ryan S
Ryan S
27,276 Points

Yes a lot of what these advanced selectors accomplish can be done using simpler selectors. But the point of the course is to teach you that they do exist and can be useful in certain circumstances. For example, say you need to style a page but you don't have the option to modify the html for whatever reason. These advanced selectors can give you other ways of selecting elements.

In the case of this video, maybe you only want to target anchor tags that link to an external website, rather than just your site's pages. Using the substring match selector could be really useful, especially if you had a lot of links scattered throughout your site and adding a class to each one individually would be a lot of work.

If you were building your own site from the ground up and had the ability to define your own classes and id's right from the start then you likely wouldn't need to use a lot of these, but they are there if you need them.

Hope this clears things up.