Change the color of <p> elements, that are immediately following sibling of a <div> element, to "red". - HTML CSS CSS

HTML CSS examples for CSS:Quiz

Description

Change the color of <p> elements, that are immediately following sibling of a <div> element, to "red".

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<head>
<style>
div + p {
    color: red;
}
</style><!-- w  w  w  .  jav a 2 s .c o  m-->
</head>
<body>

<div>
<p>This is a paragraph inside a div element.</p>
<p>This is another paragraph inside a div element.</p>
<span><p>This a paragraph inside a span element, inside a div element.</p></span>
</div>

<p>This is a paragraph, not inside a div element.</p>
<p>This is another paragraph, not inside a div element.</p>

</body>
</html>

Related Tutorials