CSS :first-child Pseudo-class
- Vorherige Seite :first
- Nächste Seite :first-of-type
- Eine Ebene zurück CSS-Pseudo-klassreferenzhandbuch
Definition and Usage
CSS :first-child
Pseudo-classes are used to select elements that are the first child of their parent element (within a group of sibling elements).
Examples
Example 1
Select and set the style of each <p> element that is the first child of its parent element:
p:first-child { background-color: yellow;
Example 2
Select and set the style of each <i> element that is the first child of its parent element:
i:first-child { background: yellow;
Example 3
Select and set the style of the first <li> element in the list:
li:first-child { background: yellow;
Example 4
Select and set the style of the first child of each <ul> element:
ul > :first-child { background: yellow;
CSS Syntax
:first-child { css declarations;
Technical Details
Version: | CSS3 |
---|
Browser Support
The numbers in the table specify the first browser version that fully supports this pseudo-class.
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
4.0 | 7.0 | 3.0 | 3.1 | 9.6 |
Verwandte Seiten
CSS-Tutorial:CSS Pseudo-Klassen
- Vorherige Seite :first
- Nächste Seite :first-of-type
- Eine Ebene zurück CSS-Pseudo-klassreferenzhandbuch