CSS chaining performance

I don't know if chaining is the right rule.
I talk about coding as follows:

    html > body > div > ul > li > a{
        /*css*/
    }

I talked with a friend of mine who told me that css coding like this gives a low level of performance in the browser when rendering css.
So is this true, or should I really only declare classes / id and point to them?

+5
source share
5 answers

If you want to apply only an element in a specific element, you can try something like this:

#ullID li{ ... }

This way you set the styles for the tags liin the #ullID element. If you want to go even deeper, you can do it like this:

#ullID li a{ ... }

, :

 html > body > div > ul > li > a{ ... }

, :)

+1

-, . , .

, .

, CSS ,

a {
/* css */
}
+3

CSS , , <a>, <li>, <html>.

, , .

+2

:

  • id (#myid)
  • class (.myclass)
  • tag (div, h1, p)
  • (h1 + p)
  • child (ul > li)
  • descendent (li a)
  • (*) 9.attribute(a [rel= "external" ])
  • (a: hover, li: first)

And this must be remembered when talking about SEO. This does not mean that you should forget about all of them and use only classe and id. The fact is that when you say div #child ul li a img, the browser first looks for both img and looks if it has a parent a, which has a parent li, etc.

+1
source

All Articles