/* Source: http://www.w3.org/Style/CSS/Test/CSS3/Selectors/current/html/tests/css3-modsel-27a.html */ :root:first-child { background-color: red; } :root:last-child { background-color: red; } :root:only-child { background-color: red; } :root:nth-child(1) { background-color: red; } :root:nth-child(n) { background-color: red; } :root:nth-last-child(1) { background-color: red; } :root:nth-last-child(n) { background-color: red; } :root:first-of-type { background-color: red; } :root:last-of-type { background-color: red; } :root:only-of-type { background-color: red; } :root:nth-of-type(1) { background-color: red; } :root:nth-of-type(n) { background-color: red; } :root:nth-last-of-type(1) { background-color: red; } :root:nth-last-of-type(n) { background-color: red; } p { color: green; }