CSS Performance Question

后端 未结 8 2024
挽巷
挽巷 2020-12-18 06:51

I was wondering what the experts do when it comes to writing CSS code. Is it bad to use the tagname.className style? Does inheritance cause a noticeable performance loss? Do

8条回答
  •  温柔的废话
    2020-12-18 07:05

    Removing the tag names isn't going to do anything but save a few bytes from the file size. I find the elm.className notation to be more comprehensible than simply throwing class name-only selectors in there. Not to mention, removing the tags will change the level of specificity for that rule. For complicated (or poorly written) CSS layouts, this could have some very unusual consequences. The performance gains would be limited to a few extra characters that the CSS parser doesn't have to read, which is going to be imperceptible.

提交回复
热议问题