:last-child
Baseline Widely available *
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
* Some parts of this feature may have varying levels of support.
Resumo
A CSS pseudo-classe :last-child
representa qualquer elemento que é o último filho de seu elemento pai.
Sintaxe
elemento:last-child { propriedades de estilo }
Exemplo
Conteúdo HTML
html
<ul>
<li>Esse item não é afetado pelo estilo.</li>
<li>Esse também não.</li>
<li>Esse item é! :)</li>
</ul>
Conteúdo CSS
css
li:last-child {
background-color: lime;
}
Especificações
Specification |
---|
Selectors Level 4 # the-last-child-pseudo |
Compatibilidade de navegadores
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
:last-child | ||||||||||||
Matches elements with no parent |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- No support
- No support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.