# 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.

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

Level: Master · [More CSS terms at this level](https://www.ask-codey.com/glossary/subjects/css/master)

Updated: September 27, 2026

Source: https://www.ask-codey.com/glossary/selector-matching
