E:only-of-type

Matches an E element, that is the only sibling of its type. (Source: W3C)

HTML:

  1. <div>
  2. <div>Lorem ipsum dolor sit amet, consectetur</div>
  3. <p>Lorem ipsum dolor sit amet, consectetur</p>
  4. <div>Lorem ipsum dolor sit amet, consectetur</div>
  5. </div>

CSS:

  1. p:only-of-type{font-style:italic}

Output:

Lorem ipsum dolor sit amet, consectetur

Lorem ipsum dolor sit amet, consectetur

Lorem ipsum dolor sit amet, consectetur

In the example, the second line of text should be set in italics as it is the only p-element in its parent element.