CSS Tutorial

CSS Style

CSS Layout Style

CSS Float Style

CSS Reference

CSS :only-child Selector

What is :only-child Selector?

CSS :only-child selector matches only single child element of an parent element.

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.


General syntax of :only-child selector,

child:only-child {
	property: value;
	property: value;

/* nth number of list item */
parent child:only-child {
	property: value;
	property: value;


CSS li:only-child selector select only one <li> element child of an <ul> parent element.

<style type="text/css">
li:only-child {
        <li>This is first line</li>
        <li>This is first line</li>
        <li>This is second line</li>
        <li>This is third line</li>
        <li>This is forth line</li>
        <li>This is fifth line</li>

Run it...   »

Example Result: