子元素选择器,选择element1元素中符合直接子元素的element2元素
注意:如果元素不是父元素的直接子元素,则不会被选择。
element1 > element2
{
CSS 样式;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>NTHOME-零基础入门学习Web(HTML5+CSS3)</title>
<style>
div>p{
color: green;
}
</style>
</head>
<body>
<div>
<h1 class="important">Welcome to nitian.web3v.vip</h1>
</div>
<div>
<p>Welcome to nitian.web3v.vip</p>
</div>
<div>
<p>Welcome to nitian.web3v.vip</p>
<p>Welcome to nitian.web3v.vip</p>
<p>Welcome to nitian.web3v.vip</p>
</div>
<p>Welcome to nitian.web3v.vip</p>
</body>
</html>
Welcome to nitian.web3v.vip
Welcome to nitian.web3v.vip
Welcome to nitian.web3v.vip
Welcome to nitian.web3v.vip
Welcome to nitian.web3v.vip
表格中的数字表示支持该属性的第一个浏览器版本号。
Safari | Chrome | FireFox | IE |
1.0 | 1.0 | 1.0 | 5.0 |