├── README.md └── debugCSS.css /README.md: -------------------------------------------------------------------------------- 1 | 2 | # debugCSS: (X)HTML debugging tool built with CSS 3 | 4 | debugCSS is meant to be loaded on an existing page to highlight potentially broken, malformed or legacy (X)HTML. 5 | 6 | Not all "errors" are created equally, so they are color coded to highlight severity. Green is "probably not a big problem", yellow is "worth looking at" and red is "you really should fix this." 7 | 8 | Each condition is specified in three areas: 9 | - Setting up the :after area for display (trying to reset common styles like colors, font sizes, etc). 10 | - Specifying the color severity (green, yellow, red) and content (which is the error or warning message to be displayed). 11 | - Creating the outline around the offending element according to it's color severity. 12 | 13 | ## Install 14 | 15 | Visit [http://imbrianj.github.com/debugCSS/](http://imbrianj.github.com/debugCSS/) to install the bookmarklet. 16 | 17 | ## License 18 | 19 | Copyrights for code authored by Yahoo! Inc. is licensed under the following terms: 20 | MIT License 21 | Copyright (c) 2011 Yahoo! Inc. All Rights Reserved. 22 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 23 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 24 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25 | -------------------------------------------------------------------------------- /debugCSS.css: -------------------------------------------------------------------------------- 1 | /***********/ 2 | /* LICENSE */ 3 | /***********/ 4 | 5 | /* Copyrights for code authored by Yahoo! Inc. is licensed under the following terms: 6 | MIT License 7 | Copyright (c) 2011 Yahoo! Inc. All Rights Reserved. 8 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 9 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 10 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 11 | */ 12 | 13 | /*****************/ 14 | /* WHAT IS THIS? */ 15 | /*****************/ 16 | 17 | /* debugCSS is meant to be loaded on an existing page to highlight potentially 18 | broken, malformed or legacy (X)HTML. Not all "errors" are created equally, 19 | so they are color coded to highlight severity. Green is "probably not a big 20 | problem", yellow is "worth looking at" and red is "you really should fix 21 | this." 22 | 23 | Red: #F88; 24 | Yellow: #FF8; 25 | Green: #8F8; 26 | */ 27 | 28 | /******************/ 29 | /* ERROR MESSAGES */ 30 | /******************/ 31 | 32 | /* All errors should try to post a message explaining the problem. */ 33 | table[summary]:after, 34 | table > *:first-child:not(caption):after, 35 | table > tr:after, 36 | table th:not([scope]):after, 37 | table thead td:after, 38 | table > colgroup ~ caption:after, 39 | table > thead ~ colgroup + *:before, 40 | table > tfoot ~ colgroup + *:before, 41 | table > tbody ~ colgroup + *:before, 42 | table > thead ~ caption:after, 43 | table > tfoot ~ caption:after, 44 | table > tbody ~ caption:after, 45 | table > tbody:first-child:after, 46 | table > tfoot ~ thead:after, 47 | table > tbody ~ tfoot:after, 48 | table > tbody ~ thead:after, 49 | table > tr:only-child:after, 50 | table > tbody > tr:only-child:after, 51 | table > *:not(thead):not(tfoot):not(tbody):not(tr):not(colgroup):not(caption):after, 52 | colgroup *:not(col):after, 53 | *[style]:after, 54 | table[align]:after, 55 | table[bgcolor]:after, 56 | table[border]:after, 57 | table[cellpadding]:after, 58 | table[cellspacing]:after, 59 | input:not([id]) ~ *:not(area):not(base):not(br):not(col):not(embed):not(hr):not(iframe):not(img):not(input):first-of-type:before, 60 | select:not([id]) ~ *:not(area):not(base):not(br):not(col):not(embed):not(hr):not(iframe):not(img):not(input):first-of-type:before, 61 | textarea:not([id]) ~ *:not(area):not(base):not(br):not(col):not(embed):not(hr):not(iframe):not(img):not(input):first-of-type:before, 62 | input:not([name]) ~ *:not(area):not(base):not(br):not(col):not(embed):not(hr):not(iframe):not(img):not(input):first-of-type:before, 63 | select:not([name]) ~ *:not(area):not(base):not(br):not(col):not(embed):not(hr):not(iframe):not(img):not(input):first-of-type:before, 64 | textarea:not([name]) ~ *:not(area):not(base):not(br):not(col):not(embed):not(hr):not(iframe):not(img):not(input):first-of-type:before, 65 | *[role="slider"]:not([aria-valuemin]):after, 66 | *[role="slider"]:not([aria-valuemax]):after, 67 | *[role="slider"]:not([aria-valuenow]):after, 68 | *[role="slider"]:not([aria-valuetext]):after, 69 | input[type="number"]:not([min]) ~ *:not(area):not(base):not(br):not(col):not(embed):not(hr):not(iframe):not(img):not(input):first-of-type:before, 70 | input[type="number"]:not([max]) ~ *:not(area):not(base):not(br):not(col):not(embed):not(hr):not(iframe):not(img):not(input):first-of-type:before, 71 | *:not(img):not(iframe)[width]:after, /* Acceptable for transitional doctypes, but should probably be relegated to CSS */ 72 | *:not(img):not(iframe)[height]:after, 73 | *[border]:after, 74 | *:not(area):not(base):not(br):not(col):not(embed):not(hr):not(iframe):not(img):not(input):not(textarea):empty:after, 75 | *[title]:empty:after, 76 | a a:after, 77 | img:not([alt]) ~ *:not(area):not(base):not(br):not(col):not(embed):not(hr):not(iframe):not(img):not(input):first-of-type:before, 78 | img[alt=""] ~ *:not(area):not(base):not(br):not(col):not(embed):not(hr):not(iframe):not(img):not(input):first-of-type:before, 79 | img:not([src]) ~ *:not(area):not(base):not(br):not(col):not(embed):not(hr):not(iframe):not(img):not(input):first-of-type:before, 80 | img[src=""] ~ *:not(area):not(base):not(br):not(col):not(embed):not(hr):not(iframe):not(img):not(input):first-of-type:before, 81 | img[src="#"] ~ *:not(area):not(base):not(br):not(col):not(embed):not(hr):not(iframe):not(img):not(input):first-of-type:before, 82 | img[src="spacer.gif"] ~ *:not(area):not(base):not(br):not(col):not(embed):not(hr):not(iframe):not(img):not(input):first-of-type:before, 83 | /* 84 | img[src*="&"]:not([src*="&"]) ~ *:not(area):not(base):not(br):not(col):not(embed):not(hr):not(iframe):not(img):not(input):first-of-type:before, 85 | a[href*="&"]:not([href*="&"]):after, 86 | */ 87 | button:empty:after, 88 | a:not([href]):after, 89 | a[href="#"]:after, 90 | a[href=""]:after, 91 | a[href*=javascript\:]:after, 92 | a[onclick]:after, 93 | a[onmouseover]:after, 94 | a[onmouseout]:after, 95 | label:not([for]):after, 96 | div[role="img"]:not([aria-label]):after, 97 | h1 div:after, 98 | h2 div:after, 99 | h3 div:after, 100 | h4 div:after, 101 | h5 div:after, 102 | h6 div:after, 103 | span div:after, 104 | html[xmlns] a div:after, /* Try to select only in XHTML documents (thanks, Thierry). */ 105 | html[xmlns] a h1:after, 106 | html[xmlns] a h2:after, 107 | html[xmlns] a h3:after, 108 | html[xmlns] a h4:after, 109 | html[xmlns] a h5:after, 110 | html[xmlns] a h6:after, 111 | ol > *:not(li):after, 112 | ul > *:not(li):after, 113 | dl > *:not(dt):not(dd):after, 114 | form > *:not(fieldset):after, 115 | fieldset > *:not(legend):first-child:after, 116 | iframe:not([title]) ~ *:not(area):not(base):not(br):not(col):not(embed):not(hr):not(iframe):not(img):not(input):first-of-type:before, 117 | center:after, 118 | u:after, 119 | font:after, 120 | map:after, 121 | br ~ *:not(area):not(base):not(br):not(col):not(embed):not(hr):not(iframe):not(img):not(input):first-of-type:before, 122 | br + br ~ *:not(area):not(base):not(br):not(col):not(embed):not(hr):not(iframe):not(img):not(input):first-of-type:before, 123 | b:after, 124 | i:after, 125 | blink:after, 126 | marquee:after, 127 | script:not([type]) ~ *:not(area):not(base):not(br):not(col):not(embed):not(hr):not(iframe):not(img):not(input):first-of-type:before, 128 | style:not([type]) ~ *:not(area):not(base):not(br):not(col):not(embed):not(hr):not(iframe):not(img):not(input):first-of-type:before, 129 | body script ~ *:not(script):before, 130 | body style ~ *:not(area):not(base):not(br):not(col):not(embed):not(hr):not(iframe):not(img):not(input):first-of-type:before, 131 | *[style="[object Object]"]:after, 132 | *[class^="1"]:after, 133 | *[class^="2"]:after, 134 | *[class^="3"]:after, 135 | *[class^="4"]:after, 136 | *[class^="5"]:after, 137 | *[class^="6"]:after, 138 | *[class^="7"]:after, 139 | *[class^="8"]:after, 140 | *[class^="9"]:after, 141 | *[class^="0"]:after, 142 | *[id^="1"]:after, 143 | *[id^="2"]:after, 144 | *[id^="3"]:after, 145 | *[id^="4"]:after, 146 | *[id^="5"]:after, 147 | *[id^="6"]:after, 148 | *[id^="7"]:after, 149 | *[id^="8"]:after, 150 | *[id^="9"]:after, 151 | *[id^="0"]:after, 152 | *[class*=left]:after, 153 | *[class*=right]:not([class*=opyright]):after, 154 | *[class*=bottom]:after, 155 | *[class*=center]:after, 156 | *[class*=clear]:after, 157 | *[class*=float]:after, 158 | *[class*=large]:after, 159 | *[class*=small]:after, 160 | *[class*=blue]:after, 161 | *[class*=green]:after, 162 | *[class*=yellow]:after, 163 | *[class*=white]:after, 164 | *[class*=black]:after, 165 | *[class*=Left]:after, 166 | *[class*=Right]:after, 167 | *[class*=Bottom]:after, 168 | *[class*=Center]:after, 169 | *[class*=Clear]:after, 170 | *[class*=Float]:after, 171 | *[class*=Large]:after, 172 | *[class*=Small]:after, 173 | *[class*=Blue]:after, 174 | *[class*=Green]:after, 175 | *[class*=Yellow]:after, 176 | *[class*=White]:after, 177 | *[class*=Black]:after, 178 | *[id*=left]:after, 179 | *[id*=right]:not([id*=opyright]):after, 180 | *[id*=bottom]:after, 181 | *[id*=center]:after, 182 | *[id*=clear]:after, 183 | *[id*=float]:after, 184 | *[id*=large]:after, 185 | *[id*=small]:after, 186 | *[id*=blue]:after, 187 | *[id*=green]:after, 188 | *[id*=yellow]:after, 189 | *[id*=white]:after, 190 | *[id*=black]:after, 191 | *[id*=Left]:after, 192 | *[id*=Right]:after, 193 | *[id*=Bottom]:after, 194 | *[id*=Center]:after, 195 | *[id*=Clear]:after, 196 | *[id*=Float]:after, 197 | *[id*=Large]:after, 198 | *[id*=Small]:after, 199 | *[id*=Blue]:after, 200 | *[id*=Green]:after, 201 | *[id*=Yellow]:after, 202 | *[id*=White]:after, 203 | *[id*=Black]:after, 204 | *[class*=\\]:after, 205 | *[class*=\.]:after, 206 | *[class*=\#]:after, 207 | *[class*=\~]:after, 208 | *[class*=\!]:after, 209 | *[class*=\@]:after, 210 | *[class*=\$]:after, 211 | *[class*=\%]:after, 212 | *[class*=\^]:after, 213 | *[class*=\&]:after, 214 | *[class*=\*]:after, 215 | *[class*=\(]:after, 216 | *[class*=\)]:after, 217 | *[class*=\=]:after, 218 | *[class*=\,]:after, 219 | *[class*=\/]:after, 220 | *[class*=\']:after, 221 | *[class*=\;]:after, 222 | *[class*=\:]:after, 223 | *[class*=\"]:after, 224 | *[class*=\?]:after, 225 | *[class*=\>]:after, 226 | *[class*=\<]:after, 227 | *[class*=\[]:after, 228 | *[class*=\]]:after, 229 | *[class*=\{]:after, 230 | *[class*=\}]:after, 231 | *[class*=\|]:after, 232 | *[class*=\`]:after, 233 | *[id*=\\]:after, 234 | *[id*=\.]:after, 235 | *[id*=\#]:after, 236 | *[id*=\~]:after, 237 | *[id*=\!]:after, 238 | *[id*=\@]:after, 239 | *[id*=\$]:after, 240 | *[id*=\%]:after, 241 | *[id*=\^]:after, 242 | *[id*=\&]:after, 243 | *[id*=\*]:after, 244 | *[id*=\(]:after, 245 | *[id*=\)]:after, 246 | *[id*=\=]:after, 247 | *[id*=\,]:after, 248 | *[id*=\/]:after, 249 | *[id*=\']:after, 250 | *[id*=\;]:after, 251 | *[id*=\:]:after, 252 | *[id*=\"]:after, 253 | *[id*=\?]:after, 254 | *[id*=\>]:after, 255 | *[id*=\<]:after, 256 | *[id*=\[]:after, 257 | *[id*=\]]:after, 258 | *[id*=\{]:after, 259 | *[id*=\}]:after, 260 | *[id*=\|]:after, 261 | *[id*=\`]:after, 262 | body:after { 263 | border: 1px solid #000; 264 | color: #000; 265 | display: block; 266 | font-family: helvetica; 267 | font-size: 12px; 268 | font-style: normal; 269 | font-weight: bold; 270 | line-height: 1.3em; 271 | padding: .1em .3em; 272 | position: absolute; 273 | text-decoration: none; 274 | text-transform: none; 275 | z-index: 99999; 276 | } 277 | 278 | /* Each error message will have a color for severity (green, yellow, red) and a 279 | message. Even if the content isn't able to be displayed (such as with 280 | images), they're used so you can quickly see the message when inspecting the 281 | element. 282 | */ 283 | 284 | table[summary]:after { 285 | background: #8F8; 286 | content: 'SUMMARY attribute is obsolete'; 287 | } 288 | 289 | table > *:first-child:not(caption):after { 290 | background: #8F8; 291 | content: 'Should you have a CAPTION on your TABLE?'; 292 | } 293 | 294 | table > tr:after { 295 | background: #FF8; 296 | content: 'TABLE does not have a TBODY'; 297 | } 298 | 299 | table th:not([scope]):after { 300 | background: #8F8; 301 | content: 'Should TH have a SCOPE attribute (ROW or COL)? OK if using ID and HEADERS'; 302 | } 303 | 304 | table thead td:after { 305 | background: #8F8; 306 | content: 'Cells in THEAD should be TH'; 307 | } 308 | 309 | table > colgroup ~ caption:after { 310 | background: #FF8; 311 | content: 'CAPTION must come before COLGROUP'; 312 | } 313 | 314 | table > thead ~ colgroup + *:before, 315 | table > tfoot ~ colgroup + *:before, 316 | table > tbody ~ colgroup + *:before { 317 | background: #FF8; 318 | content: 'COLGROUP must come before THEAD, TFOOT and TBODY'; 319 | } 320 | 321 | table > thead ~ caption:after, 322 | table > tfoot ~ caption:after, 323 | table > tbody ~ caption:after { 324 | background: #FF8; 325 | content: 'CAPTION must come before THEAD, TFOOT and TBODY'; 326 | } 327 | 328 | table > tbody:first-child:after { 329 | background: #8F8; 330 | content: 'Do you need a THEAD or TFOOT?'; 331 | } 332 | 333 | table > tfoot ~ thead:after { 334 | background: #FF8; 335 | content: 'TFOOT should come after THEAD'; 336 | } 337 | 338 | table > tbody ~ tfoot:after { 339 | background: #FF8; 340 | content: 'TBODY should come after TFOOT'; 341 | } 342 | 343 | table > tbody ~ thead:after { 344 | background: #FF8; 345 | content: 'TBODY should come after THEAD'; 346 | } 347 | 348 | table > tr:only-child:after, 349 | table > tbody > tr:only-child:after { 350 | background: #8F8; 351 | content: 'Only one TR in TABLE. Are you using it for layout?'; 352 | } 353 | 354 | table > *:not(thead):not(tfoot):not(tbody):not(tr):not(colgroup):not(caption):after { 355 | background: #FF8; 356 | content: 'Only THEAD/TFOOT/TBODY/COLGROUP/CAPTION/TR can be children of a TABLE'; 357 | } 358 | 359 | colgroup *:not(col):after { 360 | background: #FF8; 361 | content: 'Only COLs can be children of COLGROUP'; 362 | } 363 | 364 | input:not([id]) ~ *:not(area):not(base):not(br):not(col):not(embed):not(hr):not(iframe):not(img):not(input):first-of-type:before, 365 | select:not([id]) ~ *:not(area):not(base):not(br):not(col):not(embed):not(hr):not(iframe):not(img):not(input):first-of-type:before, 366 | textarea:not([id]) ~ *:not(area):not(base):not(br):not(col):not(embed):not(hr):not(iframe):not(img):not(input):first-of-type:before { 367 | background: #FF8; 368 | content: 'INPUT, SELECT and TEXTAREA should have an ID with an associated LABEL'; 369 | } 370 | 371 | input:not([name]) ~ *:not(area):not(base):not(br):not(col):not(embed):not(hr):not(iframe):not(img):not(input):first-of-type:before, 372 | select:not([name]) ~ *:not(area):not(base):not(br):not(col):not(embed):not(hr):not(iframe):not(img):not(input):first-of-type:before, 373 | textarea:not([name]) ~ *:not(area):not(base):not(br):not(col):not(embed):not(hr):not(iframe):not(img):not(input):first-of-type:before { 374 | background: #FF8; 375 | content: 'INPUT, SELECT and TEXTAREA should have a NAME value'; 376 | } 377 | 378 | *[role="slider"]:not([aria-valuemin]):after, 379 | *[role="slider"]:not([aria-valuemax]):after, 380 | *[role="slider"]:not([aria-valuenow]):after, 381 | *[role="slider"]:not([aria-valuetext]):after { 382 | background: #FF8; 383 | content: 'Sliders should have ARIA-VALUEMIN, ARIA-VALUMAX, ARIA-VALUENOW and ARIA-VALUETEXT'; 384 | } 385 | 386 | input[type="number"]:not([min]) ~ *:not(area):not(base):not(br):not(col):not(embed):not(hr):not(iframe):not(img):not(input):first-of-type:before, 387 | input[type="number"]:not([max]) ~ *:not(area):not(base):not(br):not(col):not(embed):not(hr):not(iframe):not(img):not(input):first-of-type:before { 388 | background: #8F8; 389 | content: 'INPUT type NUMBER should have a MIN and MAX value if known.'; 390 | } 391 | 392 | *[style]:after, 393 | table[align]:after, 394 | table[bgcolor]:after, 395 | table[border]:after, 396 | table[cellpadding]:after, 397 | table[cellspacing]:after, 398 | *:not(img):not(iframe)[width]:after, 399 | *:not(img):not(iframe)[height]:after, 400 | *[border]:after { 401 | background: #FF8; 402 | content: 'Element has inline style'; 403 | } 404 | 405 | *:not(area):not(base):not(br):not(col):not(embed):not(hr):not(iframe):not(img):not(input):not(textarea):empty:after { 406 | background: #FF8; 407 | content: 'Element is empty. Is this necessary?'; 408 | } 409 | 410 | *[title]:empty:after { 411 | background: #FF8; 412 | content: 'Element with title but no content. May have difficulty being read by screen readers.'; 413 | } 414 | 415 | a a:after { 416 | background: #F88; 417 | content: 'A tag within another A tag - this looks like a bug'; 418 | } 419 | 420 | img:not([alt]) ~ *:not(area):not(base):not(br):not(col):not(embed):not(hr):not(iframe):not(img):not(input):first-of-type:before { 421 | background: #FF8; 422 | content: 'Image does not have an ALT attribute'; 423 | } 424 | 425 | img[alt=""] ~ *:not(area):not(base):not(br):not(col):not(embed):not(hr):not(iframe):not(img):not(input):first-of-type:before { 426 | background: #8F8; 427 | content: 'Image has an empty ALT attribute. This image will not be read to screen readers.'; 428 | } 429 | 430 | img:not([src]) ~ *:not(area):not(base):not(br):not(col):not(embed):not(hr):not(iframe):not(img):not(input):first-of-type:before, 431 | img[src=""] ~ *:not(area):not(base):not(br):not(col):not(embed):not(hr):not(iframe):not(img):not(input):first-of-type:before, 432 | img[src="#"] ~ *:not(area):not(base):not(br):not(col):not(embed):not(hr):not(iframe):not(img):not(input):first-of-type:before { 433 | background: #F88; 434 | content: 'IMG without proper SRC attribute. Serious implications for some browsers'; 435 | } 436 | 437 | img[src="spacer.gif"] ~ *:not(area):not(base):not(br):not(col):not(embed):not(hr):not(iframe):not(img):not(input):first-of-type:before { 438 | background: #FF8; 439 | content: 'spacer.gif used - is this used for layout?'; 440 | } 441 | 442 | a[href="#"]:after, 443 | a[href=""]:after, 444 | a:not([href]):after { 445 | background: #FF8; 446 | content: 'Anchor tag is # or does not exist - does not degrade gracefully'; 447 | } 448 | 449 | a[href*=javascript\:]:after, 450 | a[onclick]:after, 451 | a[onmouseover]:after, 452 | a[onmouseout]:after { 453 | background: #FF8; 454 | content: 'Inline JS on anchor'; 455 | } 456 | 457 | label:not([for]):after { 458 | background: #FF8; 459 | content: 'Should LABEL have a FOR attribute?'; 460 | } 461 | 462 | div[role="img"]:not([aria-label]):after { 463 | background: #FF8; 464 | content: 'DIV used as image should have ARIA-LABEL'; 465 | } 466 | 467 | h1 div:after, 468 | h2 div:after, 469 | h3 div:after, 470 | h4 div:after, 471 | h5 div:after, 472 | h6 div:after, 473 | span div:after, 474 | html[xmlns] a div:after, 475 | html[xmlns] a h1:after, 476 | html[xmlns] a h2:after, 477 | html[xmlns] a h3:after, 478 | html[xmlns] a h4:after, 479 | html[xmlns] a h5:after, 480 | html[xmlns] a h6:after { 481 | background: #FF8; 482 | content: 'Block level element within inline element'; 483 | } 484 | 485 | ol > *:not(li):after, 486 | ul > *:not(li):after { 487 | background: #FF8; 488 | content: 'Only LIs can be children of UL or OL'; 489 | } 490 | 491 | dl > *:not(dt):not(dd):after { 492 | background: #FF8; 493 | content: 'Only DT/DD can be children of a DL'; 494 | } 495 | 496 | form > *:not(fieldset):after { 497 | background: #8F8; 498 | content: 'Should you be using a FIELDSET?'; 499 | } 500 | 501 | fieldset > *:not(legend):first-child:after { 502 | background: #8F8; 503 | content: 'Should your FIELDSET be using a LEGEND?'; 504 | } 505 | 506 | iframe:not([title]) ~ *:not(area):not(base):not(br):not(col):not(embed):not(hr):not(iframe):not(img):not(input):first-of-type:before { 507 | background: #FF8; 508 | content: 'IFRAME lacks TITLE attribute'; 509 | } 510 | 511 | center:after, 512 | u:after, 513 | font:after { 514 | background: #FF8; 515 | content: 'Deprecated tag used'; 516 | } 517 | 518 | *[style="[object Object]"]:after { 519 | background: #FF8; 520 | content: 'STYLE improperly set with OBJECT'; 521 | } 522 | 523 | *[class^="1"]:after, 524 | *[class^="2"]:after, 525 | *[class^="3"]:after, 526 | *[class^="4"]:after, 527 | *[class^="5"]:after, 528 | *[class^="6"]:after, 529 | *[class^="7"]:after, 530 | *[class^="8"]:after, 531 | *[class^="9"]:after, 532 | *[class^="0"]:after { 533 | background: #FF8; 534 | content: 'Class name cannot start with number'; 535 | } 536 | 537 | *[id^="1"]:after, 538 | *[id^="2"]:after, 539 | *[id^="3"]:after, 540 | *[id^="4"]:after, 541 | *[id^="5"]:after, 542 | *[id^="6"]:after, 543 | *[id^="7"]:after, 544 | *[id^="8"]:after, 545 | *[id^="9"]:after, 546 | *[id^="0"]:after { 547 | background: #FF8; 548 | content: 'ID cannot start with number'; 549 | } 550 | 551 | *[class*=left]:after, 552 | *[class*=right]:not([class*=opyright]):after, 553 | *[class*=bottom]:after, 554 | *[class*=center]:after, 555 | *[class*=clear]:after, 556 | *[class*=float]:after, 557 | *[class*=large]:after, 558 | *[class*=small]:after, 559 | *[class*=blue]:after, 560 | *[class*=green]:after, 561 | *[class*=yellow]:after, 562 | *[class*=white]:after, 563 | *[class*=black]:after, 564 | *[class*=Left]:after, 565 | *[class*=Right]:after, 566 | *[class*=Bottom]:after, 567 | *[class*=Center]:after, 568 | *[class*=Clear]:after, 569 | *[class*=Float]:after, 570 | *[class*=Large]:after, 571 | *[class*=Small]:after, 572 | *[class*=Blue]:after, 573 | *[class*=Green]:after, 574 | *[class*=Yellow]:after, 575 | *[class*=White]:after, 576 | *[class*=Black]:after { 577 | background: #8F8; 578 | /* I know that these aren't necessarily bad, but probably worth highlighting */ 579 | content: attr(class) ' has implied style meaning - should you be naming it differently?'; 580 | } 581 | 582 | *[id*=left]:after, 583 | *[id*=right]:not([id*=opyright]):after, 584 | *[id*=bottom]:after, 585 | *[id*=center]:after, 586 | *[id*=clear]:after, 587 | *[id*=float]:after, 588 | *[id*=large]:after, 589 | *[id*=small]:after, 590 | *[id*=blue]:after, 591 | *[id*=green]:after, 592 | *[id*=yellow]:after, 593 | *[id*=white]:after, 594 | *[id*=black]:after, 595 | *[id*=Left]:after, 596 | *[id*=Right]:after, 597 | *[id*=Bottom]:after, 598 | *[id*=Center]:after, 599 | *[id*=Clear]:after, 600 | *[id*=Float]:after, 601 | *[id*=Large]:after, 602 | *[id*=Small]:after, 603 | *[id*=Blue]:after, 604 | *[id*=Green]:after, 605 | *[id*=Yellow]:after, 606 | *[id*=White]:after, 607 | *[id*=Black]:after { 608 | background: #8F8; 609 | /* I know that these aren't necessarily bad, but probably worth highlighting */ 610 | content: attr(id) ' has implied style meaning - should you be naming it differently?'; 611 | } 612 | 613 | *[class*=\\]:after, 614 | *[class*=\.]:after, 615 | *[class*=\#]:after { 616 | background: #F88; 617 | content: 'Classname has an ambiguous character'; 618 | } 619 | 620 | *[id*=\\]:after, 621 | *[id*=\.]:after, 622 | *[id*=\#]:after { 623 | background: #F88; 624 | content: 'ID has an ambiguous character'; 625 | } 626 | 627 | *[class*=\~]:after, 628 | *[class*=\!]:after, 629 | *[class*=\@]:after, 630 | *[class*=\$]:after, 631 | *[class*=\%]:after, 632 | *[class*=\^]:after, 633 | *[class*=\&]:after, 634 | *[class*=\*]:after, 635 | *[class*=\(]:after, 636 | *[class*=\)]:after, 637 | *[class*=\=]:after, 638 | *[class*=\,]:after, 639 | *[class*=\/]:after, 640 | *[class*=\']:after, 641 | *[class*=\;]:after, 642 | *[class*=\:]:after, 643 | *[class*=\"]:after, 644 | *[class*=\?]:after, 645 | *[class*=\>]:after, 646 | *[class*=\<]:after, 647 | *[class*=\[]:after, 648 | *[class*=\]]:after, 649 | *[class*=\{]:after, 650 | *[class*=\}]:after, 651 | *[class*=\|]:after, 652 | *[class*=\`]:after { 653 | background: #FF8; 654 | content: 'Class has an illegal character'; 655 | } 656 | 657 | *[id*=\~]:after, 658 | *[id*=\!]:after, 659 | *[id*=\@]:after, 660 | *[id*=\$]:after, 661 | *[id*=\%]:after, 662 | *[id*=\^]:after, 663 | *[id*=\&]:after, 664 | *[id*=\*]:after, 665 | *[id*=\(]:after, 666 | *[id*=\)]:after, 667 | *[id*=\=]:after, 668 | *[id*=\,]:after, 669 | *[id*=\/]:after, 670 | *[id*=\']:after, 671 | *[id*=\;]:after, 672 | *[id*=\:]:after, 673 | *[id*=\"]:after, 674 | *[id*=\?]:after, 675 | *[id*=\>]:after, 676 | *[id*=\<]:after, 677 | *[id*=\[]:after, 678 | *[id*=\]]:after, 679 | *[id*=\{]:after, 680 | *[id*=\}]:after, 681 | *[id*=\|]:after, 682 | *[id*=\`]:after { 683 | background: #FF8; 684 | content: 'ID has an illegal character'; 685 | } 686 | 687 | /* These may not be "wrong", but let's bug you anyway. */ 688 | map:after { 689 | background: #8F8; 690 | content: 'Is MAP appropriate here?'; 691 | } 692 | 693 | br ~ *:not(area):not(base):not(br):not(col):not(embed):not(hr):not(img):not(input):first-of-type:before { 694 | background: #8F8; 695 | content: 'Is BR appropriate here?'; 696 | } 697 | 698 | br + br ~ *:not(area):not(base):not(br):not(col):not(embed):not(hr):not(iframe):not(img):not(input):first-of-type:before { 699 | background: #8F8; 700 | content: 'Should you be using a P tag?'; 701 | } 702 | 703 | b:after, 704 | i:after { 705 | background: #8F8; 706 | content: 'Should you be using STRONG or EM?'; 707 | } 708 | 709 | blink:after, 710 | marquee:after { 711 | background: #FF8; 712 | content: 'Should you be using STRONG or EM?'; 713 | } 714 | 715 | script:not([type]) ~ *:not(area):not(base):not(br):not(col):not(embed):not(hr):not(iframe):not(img):not(input):first-of-type:before { 716 | background: #8F8; 717 | content: 'script tag without type defined'; 718 | } 719 | 720 | style:not([type]) ~ *:not(area):not(base):not(br):not(col):not(embed):not(hr):not(iframe):not(img):not(input):first-of-type:before { 721 | background: #8F8; 722 | content: 'style tag without type defined'; 723 | } 724 | 725 | body script ~ *:not(script):before { 726 | background: #8F8; 727 | content: 'script tag should be at the bottom of your body'; 728 | } 729 | 730 | body style ~ *:not(area):not(base):not(br):not(col):not(embed):not(hr):not(iframe):not(img):not(input):first-of-type:before { 731 | background: #8F8; 732 | content: 'CSS should be in your head'; 733 | } 734 | 735 | /******************/ 736 | /* ERROR OUTLINES */ 737 | /******************/ 738 | 739 | /* In addition to printing the error message next to the element, outline the 740 | element so it's easy to spot. Use outline instead of border to avoid 741 | messing with the document flow. 742 | */ 743 | a a, 744 | img:not([src]), 745 | img[src=""], 746 | img[src="#"], 747 | /* 748 | img[src*="&"]:not([src*="&"]), 749 | a[href*="&"]:not([href*="&"]), 750 | */ 751 | *[class*=\\], 752 | *[class*=\.], 753 | *[class*=\#], 754 | *[id*=\\], 755 | *[id*=\.], 756 | *[id*=\#] { 757 | counter-increment: error; 758 | outline: 5px solid #F88; 759 | } 760 | 761 | table > tr, 762 | table > colgroup ~ caption, 763 | table > thead ~ colgroup, 764 | table > tfoot ~ colgroup, 765 | table > tbody ~ colgroup, 766 | table > thead ~ caption, 767 | table > tfoot ~ caption, 768 | table > tbody ~ caption, 769 | table > tfoot ~ thead, 770 | table > tbody ~ tfoot, 771 | table > tbody ~ thead, 772 | colgroup *:not(col), 773 | table > *:not(thead):not(tfoot):not(tbody):not(tr):not(colgroup):not(caption), 774 | *[style], 775 | table[align], 776 | table[bgcolor], 777 | input:not([id]), 778 | select:not([id]), 779 | textarea:not([id]), 780 | input:not([name]), 781 | select:not([name]), 782 | textarea:not([name]), 783 | *[role="slider"]:not([aria-valuemin]), 784 | *[role="slider"]:not([aria-valuemax]), 785 | *[role="slider"]:not([aria-valuenow]), 786 | *[role="slider"]:not([aria-valuetext]), 787 | input[type="number"]:not([min]), 788 | input[type="number"]:not([max]), 789 | table[border], 790 | table[cellpadding], 791 | table[cellspacing], 792 | *:not(img):not(iframe)[width], 793 | *:not(img):not(iframe)[height], 794 | *[border], 795 | *:not(area):not(base):not(br):not(col):not(embed):not(hr):not(iframe):not(img):not(input):not(textarea):empty, 796 | *[title]:empty, 797 | img:not([alt]), 798 | img[src="spacer.gif"], 799 | button:empty, 800 | a:not([href]), 801 | a[href="#"], 802 | a[href=""], 803 | a[href*=javascript\:], 804 | a[onclick], 805 | a[onmouseover], 806 | a[onmouseout], 807 | label:not([for]), 808 | div[role="img"]:not([aria-label]), 809 | h1 div, 810 | h2 div, 811 | h3 div, 812 | h4 div, 813 | h5 div, 814 | h6 div, 815 | span div, 816 | html[xmlns] a div, 817 | html[xmlns] a h1, 818 | html[xmlns] a h2, 819 | html[xmlns] a h3, 820 | html[xmlns] a h4, 821 | html[xmlns] a h5, 822 | html[xmlns] a h6, 823 | ol > *:not(li), 824 | ul > *:not(li), 825 | dl > *:not(dt):not(dd), 826 | iframe:not([title]), 827 | *[style="[object Object]"], 828 | *[class^="1"], 829 | *[class^="2"], 830 | *[class^="3"], 831 | *[class^="4"], 832 | *[class^="5"], 833 | *[class^="6"], 834 | *[class^="7"], 835 | *[class^="8"], 836 | *[class^="9"], 837 | *[class^="0"], 838 | *[id^="1"], 839 | *[id^="2"], 840 | *[id^="3"], 841 | *[id^="4"], 842 | *[id^="5"], 843 | *[id^="6"], 844 | *[id^="7"], 845 | *[id^="8"], 846 | *[id^="9"], 847 | *[id^="0"], 848 | *[class*=\~], 849 | *[class*=\!], 850 | *[class*=\@], 851 | *[class*=\$], 852 | *[class*=\%], 853 | *[class*=\^], 854 | *[class*=\&], 855 | *[class*=\*], 856 | *[class*=\(], 857 | *[class*=\)], 858 | *[class*=\=], 859 | *[class*=\,], 860 | *[class*=\/], 861 | *[class*=\'], 862 | *[class*=\;], 863 | *[class*=\:], 864 | *[class*=\?], 865 | *[class*=\>], 866 | *[class*=\<], 867 | *[class*=\[], 868 | *[class*=\]], 869 | *[class*=\{], 870 | *[class*=\}], 871 | *[class*=\|], 872 | *[class*=\`], 873 | *[id*=\~], 874 | *[id*=\!], 875 | *[id*=\@], 876 | *[id*=\$], 877 | *[id*=\%], 878 | *[id*=\^], 879 | *[id*=\&], 880 | *[id*=\*], 881 | *[id*=\(], 882 | *[id*=\)], 883 | *[id*=\=], 884 | *[id*=\,], 885 | *[id*=\/], 886 | *[id*=\'], 887 | *[id*=\;], 888 | *[id*=\:], 889 | *[id*=\?], 890 | *[id*=\>], 891 | *[id*=\<], 892 | *[id*=\[], 893 | *[id*=\]], 894 | *[id*=\{], 895 | *[id*=\}], 896 | *[id*=\|], 897 | *[id*=\`], 898 | center, 899 | u, 900 | font, 901 | blink, 902 | marquee { 903 | counter-increment: warning; 904 | outline: 5px solid #FF8; 905 | } 906 | 907 | img[alt=""], 908 | table[summary], 909 | table > *:first-child:not(caption), 910 | table th:not([scope]), 911 | table thead td, 912 | table > tr:first-child:last-child, 913 | table > tbody > tr:first-child:last-child, 914 | table > tbody:first-child, 915 | input[type="number"]:not([min]), 916 | input[type="number"]:not([max]), 917 | form > *:not(fieldset), 918 | fieldset > *:not(legend):first-child, 919 | map, 920 | br, 921 | b, 922 | i, 923 | *[class*=left], 924 | *[class*=right]:not([class*=opyright]), 925 | *[class*=bottom], 926 | *[class*=center], 927 | *[class*=clear], 928 | *[class*=float], 929 | *[class*=large], 930 | *[class*=small], 931 | *[class*=blue], 932 | *[class*=green], 933 | *[class*=yellow], 934 | *[class*=white], 935 | *[class*=black], 936 | *[class*=Left], 937 | *[class*=Right], 938 | *[class*=Bottom], 939 | *[class*=Center], 940 | *[class*=Clear], 941 | *[class*=Float], 942 | *[class*=Large], 943 | *[class*=Small], 944 | *[class*=Blue], 945 | *[class*=Green], 946 | *[class*=Yellow], 947 | *[class*=White], 948 | *[class*=Black], 949 | *[id*=left], 950 | *[id*=right]:not([id*=opyright]), 951 | *[id*=bottom], 952 | *[id*=center], 953 | *[id*=clear], 954 | *[id*=float], 955 | *[id*=large], 956 | *[id*=small], 957 | *[id*=blue], 958 | *[id*=green], 959 | *[id*=yellow], 960 | *[id*=white], 961 | *[id*=black], 962 | *[id*=Left], 963 | *[id*=Right], 964 | *[id*=Bottom], 965 | *[id*=Center], 966 | *[id*=Clear], 967 | *[id*=Float], 968 | *[id*=Large], 969 | *[id*=Small], 970 | *[id*=Blue], 971 | *[id*=Green], 972 | *[id*=Yellow], 973 | *[id*=White], 974 | *[id*=Black], 975 | script:not([type]), 976 | style:not([type]), 977 | body script ~ *:not(script), 978 | body style { 979 | counter-increment: notice; 980 | outline: 5px solid #8F8; 981 | } 982 | 983 | body { 984 | counter-reset: error warning notice; 985 | } 986 | 987 | body:after { 988 | background: #FFF; 989 | content: 'Errors: ' counter(error) ' | Warnings: ' counter(warning) ' | Notices: ' counter(notice); 990 | font-size: 125%; 991 | right: 1em; 992 | outline: 5px solid #000; 993 | position: fixed; 994 | bottom: 1em; 995 | } 996 | 997 | /*********/ 998 | /* EXTRA */ 999 | /*********/ 1000 | 1001 | /* Stuff that helps in developing / debugging, but don't quite fit anywhere 1002 | else. 1003 | */ 1004 | 1005 | body > img:only-child { 1006 | background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgAgMAAAAOFJJnAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAAlQTFRF/+Pj2tra2dnZ4Z9gVgAAAHxJREFUGBkFwUGKxDAQBDB9shqcuw2T/3TAc5+A95UruZv+IoNqvEWCavLFDB2M5vPgGpyFNOcB80cPJMxgHhLkQ4IxuBorpDA3Y+MazEfC2+gwgnOxHnSogb15F1JcGxmkcBb1AwlVqCIHadZGwt+NGmQhD1lIuB+scOUfnCk3BP0u5SsAAAAASUVORK5CYII=); 1007 | border: 50px solid rgba(0, 0, 0, 0.08); 1008 | box-shadow: 0 0 10px rgba(0, 0, 0, 0.3); 1009 | display: block; 1010 | margin: 1em auto; 1011 | padding: 0; 1012 | } 1013 | --------------------------------------------------------------------------------