forked from imbrianj/debugCSS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdebugCSS.css
301 lines (269 loc) · 7.44 KB
/
debugCSS.css
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
/***********/
/* 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."
*/
/******************/
/* ERROR MESSAGES */
/******************/
/* 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,
a[href*=javascript\:]:after,
a[onclick]:after,
a[onmouseover]:after,
a[onmouseout]:after,
label:not([for]):after,
nav:not([role]):after,
div[role="img"]:not([aria-label]):after,
h1 div:after,
h2 div:after,
h3 div:after,
h4 div:after,
h5 div:after,
h6 div:after,
a div:after,
span div:after,
html[xmlns] a h1:after, /* Try to select only in XHTML documents (thanks, Thierry). */
html[xmlns] a h2:after,
html[xmlns] a h3:after,
html[xmlns] a h4:after,
html[xmlns] a h5:after,
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,
center:after,
u:after,
font:after,
b:after,
i:after,
blink:after,
marquee:after {
border: 1px solid #000;
color: #000;
display: block;
font-family: helvetica;
font-size: 12px;
font-weight: normal;
position: absolute;
text-transform: none;
z-index: 99999;
}
/* Each error message will have a color for severity (green, yellow, red) and a
message. Even if the content isn't able to be displayed (such as with
images), they're used so you can quickly see the message when inspecting the
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.';
}
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.';
}
table > tbody:first-child:after {
background: green;
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 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[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 attribute.';
}
a[href="#"]:after,
a:not([href]):after {
background: yellow;
content: 'Anchor tag is # or does not exist - does not degrade gracefully.';
}
a[href*=javascript\:]:after,
a[onclick]:after,
a[onmouseover]:after,
a[onmouseout]:after {
background: yellow;
content: 'Inline JS on anchor.';
}
label:not([for]):after {
background: green;
content: 'Should LABEL have a FOR attribute?';
}
nav:not([role]):after {
background: yellow;
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.';
}
h1 div:after,
h2 div:after,
h3 div:after,
h4 div:after,
h5 div:after,
h6 div:after,
a div:after,
span div:after,
html[xmlns] a h1:after,
html[xmlns] a h2:after,
html[xmlns] a h3:after,
html[xmlns] a h4:after,
html[xmlns] a h5:after,
html[xmlns] a h6:after {
background: yellow;
content: 'Block level element within inline element.';
}
ol > *:not(li):after,
ul > *:not(li):after {
background: yellow;
content: 'Only LIs can be children of UL or OL';
}
dl > *:not(dt):not(dd):after {
background: yellow;
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?';
}
center:after,
u:after,
font:after {
background: yellow;
content: 'Deprecated tag used.';
}
/* These may not be "wrong", but let's bug you anyway. */
b:after,
i:after,
blink:after,
marquee:after {
background: green;
content: 'Should you be using STRONG or EM?';
}
/******************/
/* ERROR OUTLINES */
/******************/
/* In addition to printing the error message next to the element, outline the
element so it's easy to spot. Use outline instead of border to avoid
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,
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="#"],
a[href*=javascript\:],
a[onclick],
a[onmouseover],
a[onmouseout],
label:not([for]),
nav:not([role]),
div[role="img"]:not([aria-label]),
h1 div,
h2 div,
h3 div,
h4 div,
h5 div,
h6 div,
a div,
span div,
html[xmlns] a h1,
html[xmlns] a h2,
html[xmlns] a h3,
html[xmlns] a h4,
html[xmlns] a h5,
html[xmlns] a h6,
ol > *:not(li),
ul > *:not(li),
dl > *:not(dt):not(dd),
form > *:not(fieldset),
fieldset *:not(legend):first-child,
center,
u,
font,
blink,
marquee {
outline: 5px solid yellow;
}