В приведенном ниже коде я не понимаю, почему нам нужно поставить color:white
в отдельный .marked p
? Почему он не работает, если я делаю color:white
в пределах marked
? Может кто-нибудь объяснить? Спасибо заранее! :)CSS Nesting Selectors
<!DOCTYPE html>
<html>
<head>
<style>
p
{
color:blue;
text-align:center;
}
.marked
{
background-color:red;
}
.marked p
{
color:white;
}
</style>
</head>
<body>
<p>This paragraph has blue text, and is center aligned.</p>
<div class="marked">
<p>This paragraph has not blue text.</p>
</div>
<p>p elements inside a "marked" classed element keeps the alignment style, but has a different text color.</p>
</body>
</html>