E:first-of-type

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

HTML:

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

CSS:

  1. div:first-of-type{font-style:italic}

Output:

Lorem ipsum dolor sit amet, consectetur

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 first div-element in the parent element.