nth-of-invalid.html (2192B)
1 <!DOCTYPE html> 2 <html xmlns="http://www.w3.org/1999/xhtml"> 3 <head> 4 <title>Test nth-child selector argument</title> 5 <link rel="author" title="Mike Bremford" href="https://bfo.com"/> 6 <link rel="help" href="https://www.w3.org/TR/selectors-4/#the-nth-child-pseudo"/> 7 <link rel="match" href="../reference/ref-filled-green-100px-square.xht"/> 8 <style type="text/css"> 9 div { 10 display: block; 11 width: 100px; 12 height: 20px; 13 background-color: green; 14 } 15 .container { 16 height: 100px; 17 } 18 .reference { 19 background-color: green; 20 } 21 div:nth-child(1 of) { background-color: red; } 22 div:nth-last-child(n of) { background-color: red; } 23 div:nth-child(even of) { background-color: red; } 24 div:nth-last-child(even of even) { background-color: red; } /* valid just not matching */ 25 div:nth-child(even .test) { background-color: red; } 26 div:nth-last-child(of) { background-color: red; } 27 div:nth-child(of ) { background-color: red; } 28 div:nth-last-child(of .) { background-color: red; } 29 div:nth-child(of .test) { background-color: red; } 30 div:nth-last-child(n + of ) { background-color: red; } 31 div:nth-child(n - of ) { background-color: red; } 32 div:nth-last-child(n + 1of) { background-color: red; } 33 div:nth-child(+ of .test) { background-color: red; } 34 div:nth-last-child(1 + of .test) { background-color: red; } 35 div:nth-child(1 - of .test) { background-color: red; } 36 div:nth-last-child(1 n) { background-color: red } 37 div:nth-child("1" of div) { background-color: red } 38 div:nth-last-child(1 "of" div) { background-color: red } 39 div:nth-child(1 of "" div) { background-color: red } 40 div:nth-last-child(n-1of div) { background-color: red } 41 div:nth-of-type(n of div) { background-color: red } /* gotcha */ 42 div:nth-last-of-type(n of div) { background-color: red } 43 </style> 44 </head> 45 <body> 46 <p>Test passes if there is a filled green square and <strong>no red</strong>.</p> 47 <div class="container"> 48 <div class="test"></div> 49 <div class="test"></div> 50 <div class="test"></div> 51 <div class="test"></div> 52 <div class="test"></div> 53 </div> 54 </body> 55 </html>