first-child Selector

first-child Selector
CSS first-child Selector reference
The CSS first-child structural pseudo-class selector ( X:first-child { } ) is used to target and style the first child of its parent element.
CSS CODE EXAMPLE
<!DOCTYPE html>
<style type="text/css">
div:first-child {
    color:#F0F;
    font-weight:bold;
}
</style>
<div>
  <p>Paragraph content...</p>
  <p>Paragraph content...</p>
</div>
<div>
  <p>Paragraph content...</p>
  <p>Paragraph content...</p>
</div>
 
Paragraph content...
Paragraph content...
Paragraph content...
Paragraph content...

CSS CODE EXAMPLE
<style type="text/css">
div p:first-child {
    color:#F0F;
    font-weight:bold;
}
</style>
<div>
  <p>Paragraph content...</p>
  <p>Paragraph content...</p>
</div>
<div>
  <p>Paragraph content...</p>
  <p>Paragraph content...</p>
</div>
 
Paragraph content...
Paragraph content...
Paragraph content...
Paragraph content...

0 Response to "first-child Selector"

Post a Comment