CSS
CSS导入方式
1.2代码如下:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style type>
span{
color:red;
}
</style>
</head>
<body>
<div style="color:red">hello css</div>
<span>hello css</span>
</body>
</html>
3.新建CSS 文件夹
创建demo.css
p{
color:red;
}
<link>标签引入
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style type>
span{
color:red;
}
</style>
<link href="../CSS/demo.css" rel="stylesheet">
</head>
<body>
<div style="color:red">hello css</div>
<span>hello css</span>
<p> hello css </p>
</body>
</html>
CSS选择器
测试代码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
div{color:red;}
#name {
color:blue;
}
.cls{
color:yellow;
}
</style>
</head>
<body>
<div>div1</div>
<div id ="name">div2</div>
<div class="cls">div3</div>
<span class="cls">span</span>
</body>
</html>
效果