Which of the following selector selects the element that is the first child of its parent that is of its type?
Question: Which of the following selector selects the element that is the first child of its parent that is of its type?
A First-of-type
B Last-child
C First-line
D First-letter
Answer: First-of-type
Aspect | Description |
Name of Selector | First-of-type |
Usage | Selects the first child element of its type within its parent element. |
Example | p:first-of-type selects the first <p> element within its parent. |
Behavior | It targets the first occurrence of an element type within its parent, ignoring other element types. |
Similar Selectors | first-child selects the first child of any type within its parent, not just of its type. |
Compatibility | Supported in modern CSS for most web browsers. |
Common Use Cases | Styling or applying specific styles to the first occurrence of an element type within a container. |
Note | This selector helps in styling elements of a particular type when they are not necessarily the first child of the parent. |