CSS Tutorial

CSS Style

CSS Layout Style

CSS Float Style

CSS Reference

CSS :last-child Selector

What is :last-child Selector?

CSS :last-child selector matches only last child element of its 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 :last-child selector,

:last-child {
	property: value;
	property: value;

li:last-child {
	property: value;
	property: value;


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

<style type="text/css">
li:last-child {
        <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: