HTML CSS examples for CSS Selector:element sibling
The element+element selector selects elements placed immediately after the specified element.
Select every <p> element that are immediately after <div> elements:
<!DOCTYPE html> <html> <head> <style> div + p { background-color: yellow; } </style><!-- w w w . j a v a 2 s .c om--> </head> <body> <h1>Welcome to My Homepage</h1> <div> <h2>this is a test</h2> <p>this is a paragraph.</p> </div> <p>I <b>like</b> css.</p> <p>I will not be styled.</p> <div> <p>this is a paragraph.</p> </div> </body> </html>