Selector matching

Browsers read selectors right to left: the last part first.

How does the browser match selectors?

The browser reads a selector from right to left: it finds elements matching the last part, then checks their ancestors. That is why .menu a checks every link first.

.sidebar .menu li a { }   /* checks every <a>, then walks up looking for li, .menu, .sidebar */

Level: Master · More CSS terms at this level

Updated