1. Home
  2. Computing & Technology
  3. Web Design / HTML

First Child Pseudo Selector
An Expansion of the CSS Child Selector

By , About.com Guide

Once you have defined a child selector you can refine that selection even further using the CSS pseudo-selector first child. This allows you to add cascading style sheet styles to an even more specific element within a page.

Defining the first child:
  div > p:first-child { background-color : #00f; }

This means that the first paragraph in a div element would have the background color of blue, but the rest would keep the default background color.

Browser Support

The first-child pseudo-selector is not supported in IE 6 and lower for Windows or Netscape 4 for Windows. It did work in Safari and Internet Explorer 5.2 for Macintosh.

Explore Web Design / HTML
About.com Special Features

The Best Web Trends of the Decade

A look back at the best innovations, ideas and technologies over the last 10 years, More >

Family Tech Center

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

  1. Home
  2. Computing & Technology
  3. Web Design / HTML

©2010 About.com, a part of The New York Times Company.

All rights reserved.