From the course: CSS: Selectors

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Reading and writing selectors

Reading and writing selectors - CSS Tutorial

From the course: CSS: Selectors

Start my 1-month free trial

Reading and writing selectors

- [Instructor] Several times in this chapter, I have mentioned writing selectors from left to right but reading them from right to left. What on earth am I talking about? When reading and understanding a selector, especially a complex selector with several components start at the last item in the selector and expand from there. For example in this selector we start with a, then we're going to move to p, and finally we'll go to the class of warning. So in other words this selects any a element, descended from a p element, that is a child of any element with a class of warning. However, when we write selectors we're going to start at the outside, getting more and more specific as we move inwards. Being able to read selectors is the first step in understanding them well. For example, consider these two selectors which are commonly confused. Note that the first selector has no space, while the second selector does have a space in the middle. If you practice reading these from right to…

Contents