Skip to content
  1. Why do we need to initialize CSS styles?

Why do we need to initialize CSS styles?

Because of browser compatibility issues, some tags have different default values in different browsers. If CSS is not initialized, the page display might vary between browsers. Common initialization styles include removing default styles from tags, such as margin and padding, and setting default font size and font, to ensure consistent display across different browsers.

查看中文 为什么要初始化CSS样式?

因为浏览器的兼容性问题,在不同浏览器中有些标签的默认值是不同的。如果没有对 CSS 进行初始化,那么页面在不同的浏览器之间显示可能会有差异。一般常用的初始化样式操作是去掉标签的默认样式,比如 margin 和 padding,设置默认的字体大小和字体等,以便在不同浏览器中显示效果一致。