Edit This Code:
<!DOCTYPE html>
<html>
<head>
<style>
p:only-child {
    background: #ff0000;
}

</style>
</head>
<body>

<div><p>This is a paragraph.</p></div>

<div><span>This is a span.</span><p>This is a paragraph.</p></div>

<p><b>Note:</b> Internet Explorer 8 and earlier versions do not support the :only-child selector.</p>

</body>
</html>


Result:
Try it Yourself - © w3schools.com
Privacy Policy