/*! a11y-debug.css | MIT License | github.com/manuelsanchez2/a11y-debug-stylesheet */
/* ==========================================================================
Variables
========================================================================== */
/**
* These are the color variables used across all debug styles.
* You can override them in your own CSS to customize the look.
*/
:root {
--color-debug-dark: #121212;
--color-debug-dark-rgb: 18, 18, 18;
--color-debug-light: #ffffff;
--color-debug-info: oklch(0.709 0.112 274.8);
--color-debug-light-info: oklch(0.925 0.062 274.8);
--color-debug-warning: oklch(0.823 0.194 64.0);
--color-debug-light-warning: oklch(0.925 0.062 64.0);
--color-debug-error: oklch(0.603 0.183 25.3);
--color-debug-light-error: oklch(0.885 0.062 18.334);
}
/* ==========================================================================
Accessibility Debug Styles
========================================================================== */
.a11y-debug {
/* --------------------------------------------------------------------------
Role without Keyboard Support
--------------------------------------------------------------------------
Highlight elements with role="button" or role="link" that are not
natively interactive and might lack keyboard interaction.
*/
[role="button"],
[role="link"] {
outline: 2px dashed var(--color-debug-warning);
outline-offset: 4px;
position: relative;
}
[role="button"]::after,
[role="link"]::after {
content: "⚠️ Role needs keyboard support";
color: var(--color-debug-warning);
font-size: 0.675rem;
font-weight: bold;
display: block;
margin-top: 0.25em;
border: 1px solid var(--color-debug-dark);
background-color: var(--color-debug-light);
padding: 0.25em 0.75em;
border-radius: 1.25em;
}
/* --------------------------------------------------------------------------
Missing
in
--------------------------------------------------------------------------
Visually identify tables without a caption element.
*/
table:not(:has(caption)) {
outline: 2px dashed var(--color-debug-error);
outline-offset: 4px;
position: relative;
width: 100%;
}
table:not(:has(caption))::after {
content: "❌ Table missing ";
color: var(--color-debug-dark);
font-size: 0.675rem;
font-weight: bold;
display: block;
margin-block: 0.25em;
background-color: var(--color-debug-light-error);
border: 1px solid var(--color-debug-dark);
padding: 0.25em 0.75em;
border-radius: 1.25em;
width: fit-content;
}
/* --------------------------------------------------------------------------
Non- Elements in Lists
--------------------------------------------------------------------------
Warn if or has direct children that are not - .
*/
ul:has(> :not(li)),
ol:has(> :not(li)) {
outline: 2px dashed var(--color-debug-warning);
outline-offset: 4px;
position: relative;
}
ul:has(> :not(li))::before,
ol:has(> :not(li))::before {
content: "⚠️ List has children that aren't
- ";
color: var(--color-debug-warning);
font-size: 0.675rem;
font-weight: bold;
display: block;
margin-top: 0.25em;
border: 1px solid var(--color-debug-dark);
background-color: var(--color-debug-light);
padding: 0.25em 0.75em;
border-radius: 1.25em;
width: fit-content;
}
/* --------------------------------------------------------------------------
Empty Headings
--------------------------------------------------------------------------
Mark any heading tags that are visually present but have no content.
*/
h1:empty,
h2:empty,
h3:empty,
h4:empty,
h5:empty,
h6:empty {
outline: 2px solid var(--color-debug-error);
outline-offset: 4px;
position: relative;
}
h1:empty::before,
h2:empty::before,
h3:empty::before,
h4:empty::before,
h5:empty::before,
h6:empty::before {
content: "⚠️ Empty heading";
color: var(--color-debug-warning);
font-size: 0.675rem;
font-weight: bold;
display: block;
margin-top: 0.25em;
border: 1px solid var(--color-debug-dark);
background-color: var(--color-debug-light);
padding: 0.25em 0.75em;
border-radius: 1.25em;
width: fit-content;
}
/* --------------------------------------------------------------------------
Missing Alt Text on Images
--------------------------------------------------------------------------
Detect
elements without an alt attribute inside any container.
*/
*:has(> img:not([alt])) {
outline: 2px dashed var(--color-debug-error);
outline-offset: 4px;
position: relative;
}
*:has(> img:not([alt]))::after {
content: "❌ Image missing alt text";
color: var(--color-debug-dark);
font-size: 0.675rem;
font-weight: bold;
display: block;
margin-top: 0.25em;
background-color: var(--color-debug-light-error);
border: 1px solid var(--color-debug-dark);
padding: 0.25em 0.75em;
border-radius: 1.25em;
width: fit-content;
}
/* --------------------------------------------------------------------------
Label without Associated Control
--------------------------------------------------------------------------
Highlight