Hosting Solutions
mobile_logo Table of Contents
seal_frontseal_back

only child

The only-child structural pseudo-class selector will target elements where they are the only child in their parent element.
Syntax Logicelement:only-child { property_list }

CSS Code Example

<style> button:only-child { background: darkred; color: white; padding: 10px; border-radius: 4px; cursor: pointer; } </style> <div> <button>Button 1</button> <button>Button 2</button> <button>Button 3</button> <button>Button 4</button> </div> <div> <button>Button 5</button> </div>

CSS

Selectors

universaltypecompoundclassidnotattributedescendantchildadjacent siblinggeneral siblingfirst childlast childonly childfirst of typelast of typeonly of typenth childnth last childnth of typenth last of typeemptyrootfirst linefirst letterbeforeafterlinkvisitedhoveractivefocustargetenableddisabledcheckedlang