0

I just started to seriously study CSS and went through practicing my CSS skills. One particular issue I encountered was the first element on top would usually like to have a margin/padding on certain browsers.

So my question come down to, is it a good practice to do

* {
  margin: 0px;
  padding: 0px;
  border: 0px;
}

on my CSS documents? I am reading mixed answers on this. Some say this makes compatibility across browsers awesome and some say it makes rendering slow (not a good idea on older systems).

EDIT: I just researched into reset.css it seems very similar to what resetting * would do. I happen to come across normalize.css is that a better alternative to make it compatible across browsers?

EDIT2: Thanks for all the suggestions. I now understand this issue a little bit more and it seems highly opinionated. It's just a question that will never go away due to the different ways browsers render their content.

4

2 回答 2

1

这一切都取决于。* reset、normalize 和 reset.css 都重置用户代理样式。哪个最好?取决于您的文件。
* 受到批评,因为它重置了所有内容,但如果您的文档中没有太多内容,那也没关系。

reset.css 是标准,但如果您不使用它正在重置的所有元素,这可能会有点过分。

normalize 是较轻的重置版本,但同样适用。

我使用标准化。

于 2013-08-08T05:11:22.917 回答
1

您还可以在 html 中使用 reset.css。YUI 2: Reset CSS有一个你可以下载或链接到的。

它基本上为所有内容提供默认值,因此用户的浏览器显示不同内容的可能性较小。

于 2013-08-08T03:54:21.227 回答