Why not reset CSS using the asterisk? [duplicate]

烈酒焚心 提交于 2019-12-10 15:48:29

问题


Possible Duplicate:
(why) is the CSS star selector considered harmful?

I noticed that many CSS developers reset the margin, font and padding of a big number of HTML elements by explicitly declaring them all in the beginning (e.g.Yahoo and meyerweb versions). So I ask myself, why not simple reset globally using the *? I know that this break the layout for some elements like buttons and blockquotes but those can easily be restyled, which is a must if you really want to reset the layout because buttons have different looks in all browsers.


回答1:


I think you just answered yourself - it's not simple restyling buttons and form controls because all user agents have very specific styling catering toward them.




回答2:


I think the idea of targeting specific controls was to improve performance. Apparently the "*" selector is very expensive. Otherwise, I don't believe using something like the below would have much impact other than performance ( Which is debatable I suppose )

* { margin:0; padding:0; }


来源:https://stackoverflow.com/questions/5071203/why-not-reset-css-using-the-asterisk

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!