Descendant Child Selectors:
/* Descendant and Child combinators*/
INDEX.HTML:
<!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>CSS Tutorial</title>
<link rel="stylesheet" href="styles.css">
</head>
<body >
<div class="header">
<h1 >i'm child and descendant</h1>
</div>
<div class="header">
<ul>
<li><h1>i'm descendant</h1></li>
</ul>
</div>
</body>
</html>
CSS:
/* Descendant and Child combinators*/
.header h1 {
color: green;
}
.header > h1 {
color: purple;
}
div h1 {
color: red;
}
div > h1 {
color: blue;
}
评论
发表评论