CSS3 > Selectors

First-of-type selector in CSS3

How to match every first child of its parent in CSS3?

By using first-of-typeselector we can match the every first child of its parent element.

        p:first-of-type {

    <strong>This is Strong Statement</strong>
    <p>This is 1st paragraph.</p>
    <p>This is 2nd paragraph.</p>
    <b>This is Bold.</b>
        <p>This is the first pargarph in div.</p>
        <p>This is the second paragraph in div.</p>

In the above code snippet we have given style to the <p> element, so that the style applies to the first child of every <p> element.


 Views: 541 | Post Order: 21

Write for us