What is first child in CSS ?
The first-child is a pseudo class in CSS which represents the first element among a group of sibling elements. The :first-child Selector is used to target the first child element of it’s parent for styling.
Syntax:
:first-child {
//property
}Example:
HTML
<!DOCTYPE html> <html> <head> <style> p:first-child { background: limegreen; color: white; font-style: italic; font-size: 1.875em; } </style> </head> <body> <p>I am first child.</p> <p>I am second child.</p> <p>I am third child.</p> <p>I am last child.</p></body> </html> |
Output:






Please Login to comment...