child-indexed-no-parent.html (1111B)
1 <!doctype html> 2 <meta charset="utf-8"> 3 <title>CSS Test: child-indexed selectors should match without a parent element.</title> 4 <link rel="author" title="Emilio Cobos Álvarez" href="mailto:ecoal95@gmail.com"> 5 <link rel="help" href="https://drafts.csswg.org/selectors-4/#child-index"> 6 <link rel="match" href="child-indexed-no-parent-ref.html"> 7 <style> 8 :root:first-child #a { 9 color: green; 10 } 11 :root:nth-child(n) #b { 12 color: green; 13 } 14 :root:first-of-type #c { 15 color: green; 16 } 17 :root:nth-of-type(1) #d { 18 color: green; 19 } 20 :root:last-of-type #e { 21 color: green; 22 } 23 :root:last-child #f { 24 color: green; 25 } 26 :root:nth-last-child(1) #g { 27 color: green; 28 } 29 :root:nth-last-of-type(n) #h { 30 color: green; 31 } 32 33 #i { 34 color: green; 35 } 36 37 /* NB: not matching intentionally */ 38 :root:nth-last-child(2) #i { 39 color: red; 40 } 41 </style> 42 <p id="a">Should be green 43 <p id="b">Should be green 44 <p id="c">Should be green 45 <p id="d">Should be green 46 <p id="e">Should be green 47 <p id="f">Should be green 48 <p id="g">Should be green 49 <p id="h">Should be green 50 <p id="i">Should be green