<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<!-- 外联样式,在项目中使用较多 -->
<link rel="stylesheet" href="css文件名">
<!-- 内联样式 -->
<style>
/*元素选择器 */
span {
color: blue;
font-size: larger
}
/* 全局选择器 */
* {
color:black;
padding: 0;
}
/* 类选择器 不能使用数字命名*/
.test {
margin-top: auto;
padding: 0
}
/* ID选择器 唯一性,不能重复,不能使用数字*/
#hello {
font-size: larger;
padding: 0
}
</style>
</head>
<body>
<!-- 样式的优先级:行内样式>ID选择器>类选择器>元素选择器 -->
<!-- 行内样式 -->
<p style="color:red; font-size:larger">大家好</p>
<!-- 使用class引入类选择器里的样式, 使用id引入ID选择器里的样式 -->
<span class="test" id="hello">大家好</span>
</body>
</html>
CSS样式的使用
于 2023-01-29 16:41:36 首次发布