Як працює First Of Type?


What does first-of-type mean?

X:first-of-type means “the first child of its parent that is an X element.” X:last-of-type means “the last child of its parent that is an X element.” X:only-of-type means “an X element, provided it's the only child of its parent.”

What is the difference between first child and first-of-type?

Using :first-child is very similar to :first-of-type but with one critical difference: it is less specific. :first-child will only try to match the immediate first child of a parent element, while first-of-type will match the first occurrence of a specified element, even if it doesn't come absolutely first in the HTML.

What is first-of-type in Sass?

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.

What is first-of-type in MDN?

The :first-of-type CSS pseudo-class represents the first element of its type among a group of sibling elements. Note: As originally defined, the selected element had to have a parent. Beginning with Selectors Level 4, this is no longer required.

The :first-of-type CSS pseudo-class represents the first element of its type (tag name) among a group of sibling elements.
Definition and Usage. The CSS :first-of-type pseudo-class selects the first element of its type among a group of sibling elements.
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 …

Як працює First Of Type?
Scroll to top