Search code examples
csscss-selectorschildren

CSS: is "not a first child" selector possible?


Does CSS make possible selecting all the child elements except a first child?


Solution

  • Yes, using :not(:first-child)

    parent child:not(:first-child) { /* style */ }
    

    Example:

    div span:not(:first-child) {
        color: red;
    }
    <div>
        <span>A</span>
        <span>B</span>
        <span>C</span>
    </div>