From Web Education Community Group
< CSS‎ | Selectors
Revision as of 19:01, 21 November 2011 by Rworth (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Pseudo-class :only-of-type

The :only-of-type pseudo-class represents an element that has a parent element and whose parent element has no other element children with the same expanded element name. Same as :first-of-type:last-of-type or :nth-of-type(1):nth-last-of-type(1), but with a lower specificity.


selector:only-of-type{ properties }



   background-color: yellow;


  <h1>Only-child example</h1>
  <p>This is a paragraph.</p>
  <p>This is a paragraph.</p>

Css3 selectors only-of-type.png

CSS defines the :only-of-type pseudo-class selector in :only-of-type pseudo-class.