square-brackets-001.xht (5209B)
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 2 <html xmlns="http://www.w3.org/1999/xhtml"> 3 <head> 4 <title>CSS Test: Parser recovery after invalid '['</title> 5 <link rel="author" title="Boris Zbarsky" href="mailto:bzbarsky@mit.edu"/> 6 <link rel="reviewer" title="Ms2ger" href="mailto:Ms2ger@gmail.com"/> 7 <link rel="help" href="http://www.w3.org/TR/CSS21/syndata.html#parsing-errors"/> 8 <link rel="help" href="https://drafts.csswg.org/css-syntax-3/#css-stylesheets"/> 9 <link rel="match" href="../reference/ref-this-text-should-be-green.xht"/> 10 <meta name="flags" content="invalid" /> 11 <meta name="assert" content="When an invalid '[' is encountered where a 12 selector is expected, the CSS parser skips to 13 the matching ']' and then ignores the following 14 ruleset."/> 15 <style type="text/css"><![CDATA[ 16 p { color: red; } 17 [ 18 p { color: red !important; } 19 p { color: red !important; } 20 ] p { color: red !important; } 21 p { color: green; } 22 ]]></style> 23 </head> 24 <body> 25 <p>This text should be green.</p> 26 </body> 27 </html> 28 <!-- 29 <https://drafts.csswg.org/css-syntax/#tokenization>: 30 line 1 31 <whitespace-token> 32 <ident-token> p 33 <whitespace-token> 34 <{-token> 35 <whitespace-token> 36 <ident-token> color 37 <colon-token> 38 <whitespace-token> 39 <ident-token> red 40 <semicolon-token> 41 <whitespace-token> 42 <}-token> 43 line 2 44 <whitespace-token> 45 <[-token> 46 line 3 47 <whitespace-token> 48 <ident-token> p 49 <whitespace-token> 50 <{-token> 51 <whitespace-token> 52 <ident-token> color 53 <colon-token> 54 <whitespace-token> 55 <ident-token> red 56 <whitespace-token> 57 <delim-token> ! 58 <ident-token> important 59 <semicolon-token> 60 <whitespace-token> 61 <}-token> 62 line 4 63 <whitespace-token> 64 <ident-token> p 65 <whitespace-token> 66 <{-token> 67 <whitespace-token> 68 <ident-token> color 69 <colon-token> 70 <whitespace-token> 71 <ident-token> red 72 <whitespace-token> 73 <delim-token> ! 74 <ident-token> important 75 <semicolon-token> 76 <whitespace-token> 77 <}-token> 78 line 5 79 <whitespace-token> 80 <]-token> 81 <ident-token> p 82 <whitespace-token> 83 <{-token> 84 <whitespace-token> 85 <ident-token> color 86 <colon-token> 87 <whitespace-token> 88 <ident-token> red 89 <whitespace-token> 90 <delim-token> ! 91 <ident-token> important 92 <semicolon-token> 93 <whitespace-token> 94 <}-token> 95 line 6 96 <whitespace-token> 97 <ident-token> p 98 <whitespace-token> 99 <{-token> 100 <whitespace-token> 101 <ident-token> color 102 <colon-token> 103 <whitespace-token> 104 <ident-token> green 105 <semicolon-token> 106 <whitespace-token> 107 <}-token> 108 line 7 109 <whitespace-token> 110 111 <https://drafts.csswg.org/css-syntax/#consume-a-list-of-rules>: 112 [ 113 qualified rule { 114 prelude: [ 115 <ident-token> p 116 <whitespace-token> 117 ] 118 block: 119 simple block { 120 associated token: <{-token> 121 value: [ 122 <whitespace-token> 123 <ident-token> color 124 <colon-token> 125 <whitespace-token> 126 <ident-token> red 127 <semicolon-token> 128 <whitespace-token> 129 ] 130 } 131 } 132 qualified rule { 133 prelude: [ 134 simple block { 135 associated token: <[-token> 136 value: [ 137 <whitespace-token> 138 <ident-token> p 139 <whitespace-token> 140 simple block { 141 associated token: <{-token> 142 value: [ 143 <whitespace-token> 144 <ident-token> color 145 <colon-token> 146 <whitespace-token> 147 <ident-token> red 148 <whitespace-token> 149 <delim-token> ! 150 <ident-token> important 151 <semicolon-token> 152 <whitespace-token> 153 ] 154 } 155 <whitespace-token> 156 <ident-token> p 157 <whitespace-token> 158 simple block { 159 associated token: <{-token> 160 value: [ 161 <whitespace-token> 162 <ident-token> color 163 <colon-token> 164 <whitespace-token> 165 <ident-token> red 166 <whitespace-token> 167 <delim-token> ! 168 <ident-token> important 169 <semicolon-token> 170 <whitespace-token> 171 ] 172 } 173 <whitespace-token> 174 ] 175 } 176 <ident-token> p 177 <whitespace-token> 178 ] 179 block: 180 simple block { 181 associated token: <{-token> 182 value: [ 183 <whitespace-token> 184 <ident-token> color 185 <colon-token> 186 <whitespace-token> 187 <ident-token> red 188 <whitespace-token> 189 <delim-token> ! 190 <ident-token> important 191 <semicolon-token> 192 <whitespace-token> 193 ] 194 } 195 } 196 qualified rule { 197 prelude: [ 198 <ident-token> p 199 <whitespace-token> 200 ] 201 block: 202 simple block { 203 associated token: <{-token> 204 value: [ 205 <whitespace-token> 206 <ident-token> color 207 <colon-token> 208 <whitespace-token> 209 <ident-token> green 210 <semicolon-token> 211 <whitespace-token> 212 ] 213 } 214 } 215 ] 216 -->