--

This isn't a good comparison for multiple reasons. CSS selectors are matched from right to left, so if you have a moderately large HTML document with div, span, h1, p, etc., and you use a selector like body .section .content p {}, all p elements are matched first, then .content, and so on. In a typical project with thousands of selectors, this can add up to something significant in the end. Therefore, avoid nesting the CSS / HTML DOM structure unnecessarily. Keep everything as simple as possible.

--

--

Fidel Seehawer
Fidel Seehawer

Written by Fidel Seehawer

A father, husband, and software developer from the lovely city of Düsseldorf. With a passion for technology and a strong drive to constantly learn.

Responses (1)