Source Code:
(back to article)
Submit
Result:
Report an issue
<!DOCTYPE html> <html> <head> <title>Title of the document</title> <style> div:only-child { color: #8ebf42; font-weight: bold; } div { display: block; margin: 6px; padding: 5px; outline: 1px solid #1c87c9; } div div { display: inline-block; } </style> </head> <body> <h2>:only-child selector example</h2> <div> <div>I am an only child.</div> </div> <div> <div>I am the 1st sibling.</div> <div>I am the 2nd sibling.</div> <div> I am the 3rd sibling, <div>but this is an only child.</div> </div> </div> </body> </html>