Adjacent Sibling Combinator

  • 0


7) Adjacent Sibling Combinator

The element+element selector is used to select elements that is placed immediately after (not inside) the first specified element.


No Syntax




<html>
<head>
<style>
p + p {
   text-indent: 6em;
   margin-bottom: 0;
}
</style>
</head>
<body>

<h1>This is heading </h1>

<p> p is that is not placed immediately  </p>
<p> p is that is placed immediately after....</p>
<p> p is that is placed immediately after....</p>

<div> </div>
<p> p is that is not placed immediately </p>
<p>p is that is placed immediately after....</p>

<div> </div>
<p> p is that is not placed immediately </p>
<p>p is that is placed immediately after.....</p>

<div>
<p> p is that is not placed immediately  </p>
<p> p is that is placed immediately after....</p>
</div>

</body>
</html>





 




<html>
<head>
<style>
div+p
{
background-color:yellow;
}
</style>
</head>
<body>

<h1>Welcome to My Homepage</h1>

<div>
<h2>My name is Donald</h2>
<p>I live in Duckburg.</p>
</div>

<p>My best friend is Mickey.</p>

<p>I will not be styled.</p>

</body>
</html>





 







No comments:

Post a Comment