css叠加原则,就近原则

时间:2022-11-09 18:02:51
<html><head lang="en">
<meta charset="UTF-8">
<title></title> <!--
css遵循一个规律:
.就近原则
.叠加原则
-->
<style>
div{
color: purple;
font-size: 40px;
background-color: yellowgreen;
} p{
color: deeppink;
font-size: 50px;
}
</style> <link href="css/index.css" rel="stylesheet">
</head>
<body>
<div style="color: hotpink; background-color: red;"></div>
<div></div>
<div></div>
<div></div>
<div></div>
<p></p>
<p></p>
<p></p>
<p></p> </body></html>

index.css

div{
color: brown;
font-size: 50px;
} p{
background-color: yellow;
color: darkgreen;
font-size: 39px;
}