How ToJavaScriptMake Web StoriesQuiz GeneratorFAQ Schema GeneratorTable Maker3schools TranslateMore Tools..
Apu
Apu 11/23/2022

What is first child in CSS?

The first-child is a pseudo class in CSS that represents the first element in a group of sibling elements.

Using the first-child pseudo class, we can select the first child of a parent element.

CSS Syntax #

:first-child {
 // css here
}

Suppose you have one ol element and four li elements. Now you want to style the very first li element. You can easily select the first li element using the first-child pseudo class.

Example : Style the first <li> element in lists. #
<style>
  li:first-child {
    background-color:blue ;
    color:red;
    padding:5px ;
  }
</style>
<ol>
  <li>One</li>
  <li>Two</li>
  <li>Three</li>
</ol>
Share

What is first child in CSS?

0
The first-child is a pseudo class in CSS that represents the first element in a group of …
asked
0 answers

Write an Answer

Related Posts
Write an answer
back