How to use the first-child selector in css
This article mainly introduces how to use the first-child selector in css, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let Xiaobian take you to understand.
How do I use the CSS3:first-child selector?
The first-child selector matches the first child element in its parent element
Syntax:
Element: first-child
{
Css style
}
Example: matching
The first of the parent elements of the
element
P:first-child
{
Background-color:yellow
}
Note: all major browsers support: first-child selector. For: first-child in IE8 and earlier browsers, it must be declared.
Example of using CSS:first-child selector
Example 1: select each
And style each element in the, where the
An element is the first child of its parent element:
P:first-childi
{
Background:yellow
}
Iamastrongman.Iamastrongman.
Iamastrongman.Iamastrongman.
Effect picture:
1.jpg
Example 2: the style selected by the first child element of each element
Ul >: first-child
{
Background:yellow
}
Coffee
Tea
CocaCola
Coffee
Tea
CocaCola
Effect picture:
2.jpg
The above is the details of how to use the CSS3:first-child selector, please pay more attention to other related articles on php Chinese website!
Thank you for reading this article carefully. I hope the article "how to use first-child Selector in css" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!