不同浏览器对有些标签的默认值是不同的,为了消除不同的浏览器对HTML文本呈现的差异,照顾浏览器的兼容,我们需要对css初始化。
简单理解:css初始化是指重设浏览器的样式。(也称为css reset)
每个网页都必须首先运行css初始化。
这里我们以 京东css初始化代码为例
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>返回首页</title>
<style>
/*初始化内外边距*/
* {
margin: 0;
padding: 0;
}
em,
i {
font-style: normal;
}
li {
list-style: none;
}
img {
border: 0;
vertical-align: middle;
}
button {
cursor: pointer;
}
a {
color: #666;
text-decoration: none;
}
a:hover {
color: #c81623;
}
.hide,
.none {
display: none;
}
.clearfix:after {
visibility: hidden;
clear: both;
display: block;
content: ".";
height: 0;
}
.clearfix {
*zoom: 1;
}
</style>
</head>
<body>
<div class="box">
</div>
</body>
</html>