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

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

    It's typically not a good practice to strict type your classes and ID's to a specific element type.

    div.foo {}
    

    Will only work for Div's. Then you can't reuse that style elsewhere unless it's a Div element.

    .foo { /* Base Style */ }
    div.foo { /* Specific to if a DIV is used */ }
    

    This is a slightly better approach.

提交回复
热议问题