:last-of-type
Sumário
A CSS pseudo-class :last-of-type
representa o último irmão com o nome de elemento dado na lista de filhos de seu elemento pai.
Syntax
element:last-of-type { style properties }
Exemplo
Para selecionar o último elemento em dentro de um elemento <p>
, você pode usar o seguinte:
p em:last-of-type {
color: lime;
}
<p>
<em>I'm not lime :(</em>
<strong>I'm not lime :(</strong>
<em>I'm lime :D</em>
<strong>I'm also not lime :(</strong>
</p>
<p>
<em>I'm not lime :(</em>
<span><em>I am lime!</em></span>
<strong>I'm not lime :(</strong>
<em>I'm lime :D</em>
<span><em>I am also lime!</em> <strike> I'm not lime </strike></span>
<strong>I'm also not lime :(</strong>
</p>
...irá resultar em:
Especificações
Specification | Status | Comment |
---|---|---|
Selectors Level 4 The definition of ':last-of-type' in that specification. |
Rascunho atual | No change |
Selectors Level 3 The definition of ':last-of-type' in that specification. |
Recomendação | Initial definition |
Compatibilidade com navegadores
BCD tables only load in the browser