Explain how a browser determines what elements match a CSS selector.

Explain how a browser determines what elements match a CSS selector.

Senior Developer Asked on June 5, 2018 in CSS.
Add Comment
1 Answer(s)

The browser reads selectors from right to left so having unnecessary selectors can lead to inefficient code  if the browser can determine the target element with only one specific selector  it can be more efficient.

#nav ul li a { color: #F00; }

That means the browser first checks for a, then li, then ul, and then #nav

Default Answered on November 25, 2018.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.