Prev Demo
CSS3
>
Only-Child Selector
Next Demo
Write code here
J
|
B
|
A
<!DOCTYPE html> <html> <head> <title>Demo</title> </head> <style> p:only-child { background-color: lightblue; color: blue; } </style> <body> <p>This is the normal element</p> <div> <p>The only Child of div parent.</p> </div> <div> <p>The first child of div parent.</p> <p>The second child of div parent.</p> </div> </body> </html>
Note: We DO NOT save your trial code in our database.
Output