English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

CSS Reference Manual

CSS @rules (RULES)

Complete list of CSS properties

CSS3 :last-of-type selector

:last-of-type CSS pseudo-class indicates the last element of a given type in the list of child elements of its parent element. When the code similar to Parent tagName:last-of-type has the effect area containing the last selected element among all child elements of the parent element, including the last child element of the child elements and so on.

Manuale completo delle scelte CSS

Esempio online

Specificare il colore di sfondo dell'ultimo elemento p del genitore:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"> 
<title>Corso di base(oldtoolbag.com)</title> 
<style> 
p em:last-of-type {
  color: verde;
}
</style>
</head>
<body>
<p>
  <em>Non ho colore :(</em><br>
  <strong>Non ho colore :(</strong><br>
  <em>Ho colore :D</em><br>
  <strong>Non ho colore :(</strong><br>
</p>
<p>
  <em>Non ho colore :(</em><br>
  <span><em>Ho colore!</em></span><br>
  <strong>Non ho colore :(</strong><br>
  <em>Ho colore :D</em><br>
  <span>
    <em>Sono在内的子元素,但没有颜色!</em><br>
    <span style="text-decoration:line-through;"> Non ho colore </span><br>
    <em>Ho colore!</em><br>
  </span><br>
  <strong>Non ho colore :(</strong>
</p>
</body>
</html>
Prova a vedere ‹/›

Definizione e uso

element:last-of-type { properties dello stile }

Il selettore :last-of-type abbinamento dell'elemento il cui genitore è l'ultimo figlio di tipo specifico.

Suggerimento: e :nth-last-of-type(1) hanno lo stesso significato.

Compatibilità del browser

I numeri nella tabella rappresentano la versione del primo browser che supporta l'attributo.

Selettore




:last-of-type4.09.03.53.29.6

Manuale completo delle scelte CSS