Skip to content

Commit

Permalink
Merge pull request #1 from imbrianj/master
Browse files Browse the repository at this point in the history
Added README, added rules, fixed typo.
  • Loading branch information
imbrianj committed Oct 6, 2011
2 parents 958e099 + 1444d39 commit 3817731
Show file tree
Hide file tree
Showing 2 changed files with 120 additions and 16 deletions.
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
License
---
Copyrights for code authored by Yahoo! Inc. is licensed under the following terms:
MIT License
Copyright (c) 2011 Yahoo! Inc. All Rights Reserved.
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:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
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.

What is this?
---
debugCSS is meant to be loaded on an existing page to highlight potentially broken, malformed or legacy (X)HTML.

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."

About
---
Each condition is specified in three areas:

- Setting up the :after area for display (trying to reset common styles like colors, font sizes, etc).
- Specifying the color severity (green, yellow, red) and content (which is the error or warning message to be displayed).
- Creating the outline around the offending element according to it's color severity.
114 changes: 98 additions & 16 deletions debugCSS.css
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
/*****************/

/* debugCSS is meant to be loaded on an existing page to highlight potentially
broken, malformed or legacy code. Not all "errors" are created equally, so
they are color coded to highlight severity. Green is "probably not a big
broken, malformed or legacy (X)HTML. 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."
*/
Expand All @@ -25,13 +25,22 @@
/* ERROR MESSAGES */
/******************/

/* All errors should try to post a message explaning the problem. */
/* All errors should try to post a message explaining the problem. */
table:not([summary]):after,
table > tr:after,
table th:not([scope]):after,
table thead td:after,
table > tbody:first-child:after,
table > tbody + tfoot:after,
table > tr:first-child:last-child:after,
table > tbody > tr:first-child:last-child:after,
table > *:not(thead):not(tfoot):not(tbody):not(tr):not(colgroup):not(caption):after,
table[align]:after,
table[bgcolor]:after,
table[border]:after,
table[cellpadding]:after,
table[cellspacing]:after,
table[width]:after,
img:not([alt]):after,
a:not([href]):after,
a[href="#"]:after,
Expand Down Expand Up @@ -59,11 +68,18 @@ html[xmlns] a h6:after,
ol > *:not(li),
ul > *:not(li),
dl > *:not(dt):not(dd):after,
form > *:not(fieldset):after,
fieldset *:not(legend):first-child:after,
iframe:not([title]):after,
center:after,
u:after,
font:after,
map:after,
b:after,
i:after,
blink:after,
marquee:after {
border: 1px solid #000;
color: #000;
display: block;
font-family: helvetica;
Expand All @@ -80,35 +96,60 @@ marquee:after {
element.
*/

table:not([summary]):after {
background: green;
content: 'Should you have a SUMMARY attribute on your TABLE?';
}

table > tr:after {
background: yellow;
content: 'Table does not have a tbody';
content: 'TABLE does not have a TBODY.';
}

table th:not([scope]):after {
background: green;
content: 'Should TH have a SCOPE attribute (ROW or COL)?.';
}

table thead td:after {
background: green;
content: 'Cells in thead should be th.';
content: 'Cells in THEAD should be TH.';
}

table > tbody:first-child:after {
background: green;
content: 'Do you need a thead or tfoot?';
content: 'Do you need a THEAD or TFOOT?';
}

table > tbody + tfoot:after {
background: yellow;
content: 'TBODY should come after TFOOT.';
}

table > tr:first-child:last-child:after,
table > tbody > tr:first-child:last-child:after {
background: green;
content: 'Only one table row in table. Are you using it for layout?';
content: 'Only one TR in TABLE. Are you using it for layout?';
}

table > *:not(thead):not(tfoot):not(tbody):not(tr):not(colgroup):not(caption):after {
background: yellow;
content: 'Only THEAD/TFOOT/TBODY/COLGROUP/CAPTION/TR can be children of a TABLE';
}

table[border]:after {
table[align]:after,
table[bgcolor]:after,
table[border]:after,
table[cellpadding]:after,
table[cellspacing]:after,
table[width]:after {
background: yellow;
content: 'Element has inline style.';
}

img:not([alt]):after {
background: yellow;
content: 'Image does not have an alt tag.';
content: 'Image does not have an ALT attribute.';
}

a[href="#"]:after,
Expand All @@ -127,17 +168,17 @@ a[onmouseout]:after {

label:not([for]):after {
background: green;
content: 'Should label have a for attribute?';
content: 'Should LABEL have a FOR attribute?';
}

nav:not([role]):after {
background: yellow;
content: 'Nav element should have a role.';
content: 'NAV element should have a ROLE attribute.';
}

div[role="img"]:not([aria-label]):after {
background: yellow;
content: 'Div used as image should have aria-label';
content: 'DIV used as image should have ARIA-LABEL.';
}

h1 div:after,
Expand Down Expand Up @@ -169,18 +210,44 @@ dl > *:not(dt):not(dd):after {
content: 'Only DT/DD can be children of a DL';
}

form > *:not(fieldset):after {
background: green;
content: 'Should you be using a FIELDSET?';
}

fieldset *:not(legend):first-child:after {
background: green;
content: 'Should your FIELDSET be using a LEGEND?';
}

iframe:not([title]):after {
background: green;
content: 'IFRAME lacks TITLE attribute.';
}

center:after,
u:after,
font:after {
background: yellow;
content: 'Deprecated tag used.';
}

/* These may not be "wrong", but let's bug you anyway. */
map:after {
background: green;
content: 'Is MAP appropriate here?';
}

b:after,
i:after,
i:after {
background: green;
content: 'Should you be using STRONG or EM?';
}

blink:after,
marquee:after {
background: green;
content: 'Should you be using strong or em?';
background: yellow;
content: 'Should you be using STRONG or EM?';
}

/******************/
Expand All @@ -192,17 +259,27 @@ marquee:after {
messing with the document flow.
*/

table:not([summary]),
table th:not([scope]),
table thead td,
table > tr:first-child:last-child,
table > tbody > tr:first-child:last-child,
table > tbody:first-child,
map,
b,
i {
outline: 5px solid green;
}

table > tr,
table > tbody + tfoot,
table > *:not(thead):not(tfoot):not(tbody):not(tr):not(colgroup):not(caption),
table[align],
table[bgcolor],
table[border],
table[cellpadding],
table[cellspacing],
table[width],
img:not([alt]),
a:not([href]),
a[href="#"],
Expand All @@ -229,7 +306,12 @@ html[xmlns] a h5,
html[xmlns] a h6,
ol > *:not(li),
ul > *:not(li),
dl > *:not(dt):not(dd):after,
dl > *:not(dt):not(dd),
form > *:not(fieldset),
fieldset *:not(legend):first-child,
iframe:not([title]),
center,
u,
font,
blink,
marquee {
Expand Down

0 comments on commit 3817731

Please sign in to comment.