CSS基础学习之路–03 id选择器!

id选择器

id选择器可以为标有id的HTML元素指定特定的样式
id选择器以“#”来定义

id选择器和派生选择器

目前比较常用的方式是id选择器常常用于建立派生选择器

id选择器使用

index.html

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link href="demo.css" type="text/css" ref="stylesheet">
</head>
<body>
<p id="pid">Hello JhonRain </p>
<div id="divId">
这是一个Div
</div>

<p id="ppid">Hell JhonRain <a href="https://hongsir15.github.io/">Blog</p>
</body>
</html>

demo.css

1
2
3
4
5
6
7
8
9
10
11
#pid{
color:red;
}

#ppid a{
color:green;
}

#divId{
color:blue;
}

最后更新: 2018年09月26日 12:02

原始链接: http://yoursite.com/2016/03/09/CSS/CSSid选择器/

× 请我吃糖~
打赏二维码