Use the CSS :only-of-type selector to style every <p> element that is the only <p> element of its parent.
Example
You can try to run the following code to implement the :only-of-type selector:
<!DOCTYPE html> <html> <head> <style> p:only-of-type { background: orange; color: white; } </style> </head> <body> <div> <p>This is demo text 1.</p> </div> <div> <p>This is demo text 2.</p> <p>This is demo text 3.</p> <p>This is demo text 4.</p> </div> </body> </html>