Does the order of rules in a CSS stylesheet affect rendering speed?

后端 未结 6 1521
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-13 17:45

While this could possibly result in a simple yes or no answer I\'ll go for it anyway


Consider the following example:

HTML

6条回答
  •  不知归路
    2021-02-13 18:21

    It matters for the importance of your selectors, adding details such as classes or IDs or parent elements will increase the importance of that rule over others.

    Also, it may or may not decrease the speed of the browser who have to interpret it, but for sure it will increase the size of your CSS file to download and possibly be cached (not all handheld devices cache files bigger than a specified size).

    CSS selectors specificity

提交回复
热议问题