<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<!--内部样式-->
<!--避免使用,class,id选择器-->
<style>
/*ul的第一个子元素*/
ul li:first-child{
background: #27b3b3;
}
/*ul的最后一个子元素*/
ul li:last-child{
background: antiquewhite;
}
/*选中p1 :
定位到当前元素的父元素,选择第一个元素
选择p元素的父级,选中父级元素的第一个,并且是当前元素
也就是说,如果父级元素的第一个子元素不是p标签则无效
*/
p:nth-child(1){
background: #ff3fc1;
}
/*选中当前p元素的父元素的第二个类型为p的子元素*/
p:nth-of-type(2){
background: yellow;
}
/*伪类选择器, 鼠标移动到该位置就会自动显示css属性,如颜色*/
a:hover{
background: #1c63a7;
}
</style>
</head>
<body>
<p>周五</p>
<p>周四</p>
<h1>h1标题</h1>
<h2>h2标题</h2>
<h3>h3标题</h3>
<ul>
<li></li>
<li></li>
<li></li>
</ul>
</body>
</html>