The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS [Solved] First-of-type affecting elements further down Reply To: First-of-type affecting elements further down


The :first-of-type selector in CSS allows you to target the first occurence of an element within its container. It is defined in the CSS Selectors Level 3 spec as a “structural pseudo-class”, meaning it is used to style content based on its relationship with parent and sibling content.

So header img:first-of-type will select the first image inside ANY container provided that the container is within the header header.

Overall, it would be much easier to just give that image a class or ID and use that in your media query.