Search code examples
csscss-selectorspseudo-class

:last-of-type Pseudo-Class Not Acting as Expected


I'm applying :last-of-type to an element that should be as such. Check out the final div.info (that's the bottom information for each article) on http://www.elemovements.com. Why is it not working?


Solution

  • The :nth-of-type() family of pseudo-classes only look at an element's type, that is, its tag name. They do not filter by your class selector or any other selector.

    Therefore, your statements:

    I'm applying :last-of-type to an element that is clearly as such. Check out the final div.info

    Are contradictory. There's a div.center after that, making that the last div, not your div.info.

    You cannot currently use CSS selectors to find your last div.info; you'll have to resort to adding an extra class and/or using JavaScript.