Skip to content
Related Articles

Related Articles

Improve Article

How to use a not:first-child selector in CSS?

  • Difficulty Level : Medium
  • Last Updated : 04 Dec, 2018

This selector is used to select every element which is not the first-child of its parent element. It is represented as an argument in the form of :not(first-child) element.


:not( element ) {
  // CSS property


<!DOCTYPE html>
        <title>not first child selector</title>
            h1 {
            div ul:not(:first-child) {
                background-color: green;
            h1, h2 {
        <h2>not:first-child selector </h2>
            <ul style="margin-left:100px">


Explanation: The above example shows that a <div> is a container Tag. It contains <ul> Tag so it selects all child elements of <div> tag except its first-child.

Supported Browsers: The browser supported by :not:(first-child) selectors are listed below:

  • Apple Safari 3.1
  • Google Chrome 4.0
  • Firefox 3.0
  • Opera 9.6
  • Internet Explorer 7.0

Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.

My Personal Notes arrow_drop_up
Recommended Articles
Page :