Is this using CSS to target nested divs?

basically just want to know if the attached image shows acceptable CSS usage? I’ve been using a lot of nested divs lately, and that is how I target them in my CSS. This works very well, but I'm just wondering if this is a good way to do this? Or is there an easier / more efficient way?

Thank!

Illustrationimage link

+4
source share
2 answers

First of all: your path is completely in order, and the effectiveness depends on the entire page. Maybe it can become more efficient with these ideas:

If your div classes or identifiers are unique

- .

#content > .inner > .content > div { }

.content > div { }

, div

div- :

#content > .inner > .content { }
#content > .inner > .content > div {}
#content > .inner > .footer {}
#content > .inner > .footer > div {}

, LESS SASS ( ). ,

#content {
   .inner {
      .content {
         // some stuff
         div {
            // some stuff
         }
      }
      .footer {
         //some stuff
         div {
            // some stuff
         }
      }
   }
}
+3

(.. > ) , , . , .content -, #container, CSS. CSS.

, . , .content > p, , , . , .

+1

Source: https://habr.com/ru/post/1542789/


All Articles