CSS first-child Selector (:first-child)

What is CSS :first-child Selector?

CSS :first-child selector matches only first child element of its parent element.


General syntax of CSS :first-child selector,

:empty {
  property: value;
  property: value;

div:empty {
  property: value;
  property: value;


CSS :first-child selector select only first <li> element of its <ul> parent element.

<!DOCTYPE html>
  <title>CSS :first-child Selector</title>
  <style type="text/css">
    li:first-child {
  <li>first item</li>
  <li>second item</li>
  <li>third item</li>
  <li>forth item</li>
  <li>fifth item</li>

Run it...   »

Browser Compatibility

  • Google Chrome 2+
  • Mozilla Firefox 3+
  • Internet Explorer 9+
  • Opera 9.5+
  • Safari 4+

Note: Here details of browser compatibility with version number may be this is bug and not supported. But recommended to always use latest Web browser.