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

后端 未结 6 1520
爱一瞬间的悲伤
爱一瞬间的悲伤 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:35

    The order doesn't matter in loading speed, it only matters when the styles cascade down, so you can't move them around willy-nilly. Using IDs may be faster than using classes, but you can only have one ID on a page. The best way to speed it up would be searching for things that have a class but are only used once, and changing it to an ID.

提交回复
热议问题