Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

css child selector select the last div

Tags:

css

<body>
    <div>content 1</div>
    <div>content 2</div>
    <div>content 3</div>
</body>

how do i select the last tag without using any id or class. I have already tried:

body:last-child {
        clear: both;
        background-color:red;
}

Please help

Thank you

but it's this is css3 so the browser (ipad safari) does not recoginsed it.

like image 491
thelinh bui Avatar asked Mar 05 '26 14:03

thelinh bui


1 Answers

body:last-child selects a body tag that is the last child of its parent, try

body > :last-child
like image 55
Musa Avatar answered Mar 07 '26 05:03

Musa