
Web Platform Design
- 9 installs
- 33 repo stars
- Updated July 27, 2026
- dirnbauer/webconsulting-skills
Build accessible, responsive, performant web interfaces using framework-agnostic rules grounded in WCAG 2.2 and MDN.
About
This skill provides framework-agnostic web platform design rules for accessible, performant, responsive interfaces based on WCAG 2.2 and MDN. A developer uses it when building web UI, auditing accessibility, or reviewing responsive and performance behavior.
- Framework-agnostic rules based on WCAG 2.2, MDN, and modern web platform APIs
- Covers semantic HTML, accessibility, responsive layout, and web performance
Web Platform Design by the numbers
- 9 all-time installs (skills.sh)
- Ranked #1,468 of 1,880 Design & UI/UX skills by installs in the Skillselion catalog
- Data as of Jul 29, 2026 (Skillselion catalog sync)
npx skills add https://github.com/dirnbauer/webconsulting-skills --skill web-platform-designAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 9 |
|---|---|
| repo stars | ★ 33 |
| Last updated | July 27, 2026 |
| Repository | dirnbauer/webconsulting-skills ↗ |
What it does
Build accessible, responsive, performant web interfaces using framework-agnostic rules grounded in WCAG 2.2 and MDN.
Files
Web Platform Design Guidelines
Framework-agnostic rules for accessible, performant, responsive web interfaces. Based on WCAG 2.2, MDN Web Docs, and modern web platform APIs.
---
1. Accessibility / WCAG [CRITICAL]
Accessibility is not optional. Most rules in this section map to WCAG 2.2 success criteria at Level A or AA. A small number of best-practice rules (noted inline) target Level AAA or go beyond WCAG.
1.1 Use Semantic HTML Elements
Use elements for their intended purpose. Semantic structure provides free accessibility, SEO, and reader-mode support.
| Element | Purpose |
|---|---|
<main> | Primary page content (one per page) |
<nav> | Navigation blocks |
<header> | Introductory content or navigational aids |
<footer> | Footer for nearest sectioning content |
<article> | Self-contained, independently distributable content |
<section> | Thematic grouping with a heading |
<aside> | Tangentially related content (sidebars, callouts) |
<figure> / <figcaption> | Illustrations, diagrams, code listings |
<details> / <summary> | Expandable/collapsible disclosure widget |
<dialog> | Modal or non-modal dialog boxes |
<time> | Machine-readable dates/times |
<mark> | Highlighted/referenced text |
<address> | Contact information for nearest article/body |
<!-- Good -->
<main>
<article>
<h1>Article Title</h1>
<p>Content...</p>
</article>
<aside>Related links</aside>
</main>
<!-- Bad: div soup -->
<div class="main">
<div class="article">
<div class="title">Article Title</div>
<div class="content">Content...</div>
</div>
</div>Anti-pattern: Using <div> or <span> for interactive elements. Never write <div onclick> when <button> exists.
1.2 ARIA Labels on Interactive Elements
Every interactive element must have an accessible name. Prefer visible text; use aria-label or aria-labelledby only when visible text is insufficient (SC 4.1.2).
<!-- Icon-only button: needs aria-label -->
<button aria-label="Close dialog">
<svg aria-hidden="true">...</svg>
</button>
<!-- Linked by labelledby -->
<h2 id="section-title">Notifications</h2>
<ul aria-labelledby="section-title">...</ul>
<!-- Redundant: visible text is enough -->
<button>Save Changes</button> <!-- No aria-label needed -->1.3 Keyboard Navigation
All interactive elements must be reachable and operable via keyboard (SC 2.1.1).
- Use native interactive elements (
<button>,<a href>,<input>,<select>) which are keyboard-accessible by default. - Custom widgets need
tabindex="0"to enter tab order and keydown handlers for activation. - Never use
tabindexvalues greater than 0. - Trap focus inside modals; return focus on close.
// Focus trap for modal
dialog.addEventListener('keydown', (e) => {
if (e.key === 'Tab') {
const focusable = dialog.querySelectorAll(
'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'
);
const first = focusable[0];
const last = focusable[focusable.length - 1];
if (e.shiftKey && document.activeElement === first) {
e.preventDefault();
last.focus();
} else if (!e.shiftKey && document.activeElement === last) {
e.preventDefault();
first.focus();
}
}
});1.4 Visible Focus Indicators
Never remove focus outlines without providing a visible replacement (SC 2.4.7, enhanced SC 2.4.11 (AA) and SC 2.4.12 (AAA) in WCAG 2.2).
/* Good: custom focus indicator */
:focus-visible {
outline: 3px solid var(--focus-color, #4A90D9);
outline-offset: 2px;
}
/* Remove default only when :focus-visible is supported */
:focus:not(:focus-visible) {
outline: none;
}
/* Bad: removing all focus styles */
/* *:focus { outline: none; } */WCAG 2.2 requires focus indicators to have a minimum area of the perimeter of the component times 2px, with 3:1 contrast against adjacent colors.
1.5 Skip Navigation Links
Provide a mechanism to skip repeated blocks of content (SC 2.4.1).
<body>
<a href="#main-content" class="skip-link">Skip to main content</a>
<nav>...</nav>
<main id="main-content">...</main>
</body>.skip-link {
position: absolute;
top: -100%;
left: 0;
z-index: 1000;
padding: 0.75rem 1.5rem;
background: var(--color-primary);
color: var(--color-on-primary);
}
.skip-link:focus {
top: 0;
}1.6 Alt Text for Images
Every <img> must have an alt attribute (SC 1.1.1).
- Informative images: describe the content and function.
alt="Bar chart showing sales doubled in Q4". - Decorative images: use
alt=""(empty string) so screen readers skip them. - Functional images (inside links/buttons): describe the action.
alt="Search". - Complex images: use
altfor short description, link to long description or use<figcaption>.
<img src="chart.png" alt="Revenue chart: Q1 $2M, Q2 $2.4M, Q3 $3.1M, Q4 $4.5M">
<img src="decorative-wave.svg" alt="">1.7 Color Contrast
Maintain minimum contrast ratios (SC 1.4.3, 1.4.6, 1.4.11).
| Content | Minimum Ratio |
|---|---|
| Normal text (<24px / <18.66px bold) | 4.5:1 |
| Large text (>=24px / >=18.66px bold) | 3:1 |
| UI components and graphical objects | 3:1 |
Do not rely on color alone to convey information (SC 1.4.1). Pair color with icons, text, or patterns.
/* Check contrast of these tokens */
:root {
--text-primary: #1a1a2e; /* on white: ~16:1 */
--text-secondary: #555770; /* on white: ~6.5:1 */
--text-disabled: #767693; /* on white: ~4.5:1, borderline */
}1.8 Form Labels
Every form input must have a programmatically associated label (SC 1.3.1, 3.3.2).
<!-- Explicit label (preferred) -->
<label for="email">Email address</label>
<input id="email" type="email" autocomplete="email">
<!-- Implicit label (acceptable) -->
<label>
Email address
<input type="email" autocomplete="email">
</label>
<!-- Never: placeholder as sole label -->
<!-- <input placeholder="Email"> -->1.9 Error Identification
Identify and describe errors in text (SC 3.3.1). Link error messages to inputs with aria-describedby or aria-errormessage.
<label for="email">Email</label>
<input id="email" type="email" aria-describedby="email-error" aria-invalid="true">
<p id="email-error" role="alert">Enter a valid email address, e.g. name@example.com</p>1.10 ARIA Live Regions
Announce dynamic content changes to screen readers (SC 4.1.3).
<!-- Polite: announced when user is idle -->
<div aria-live="polite" aria-atomic="true">
3 results found
</div>
<!-- Assertive: interrupts current speech -->
<div role="alert">
Your session will expire in 2 minutes.
</div>
<!-- Status messages -->
<div role="status">
File uploaded successfully.
</div>Use aria-live="polite" by default. Reserve role="alert" / aria-live="assertive" for time-sensitive warnings.
1.11 ARIA Role Quick Reference
| Role | Purpose | Native Equivalent |
|---|---|---|
button | Clickable action | <button> |
link | Navigation | <a href> |
tab / tablist / tabpanel | Tab interface | None |
dialog | Modal | <dialog> |
alert | Assertive live region | None |
status | Polite live region | <output> |
navigation | Nav landmark | <nav> |
main | Main landmark | <main> |
complementary | Aside landmark | <aside> |
search | Search landmark | <search> (HTML5) |
img | Image | <img> |
list / listitem | List | <ul>/<li> |
heading | Heading (with aria-level) | <h1>-<h6> |
menu / menuitem | Menu widget | None |
tree / treeitem | Tree view | None |
grid / row / gridcell | Data grid | <table> |
progressbar | Progress | <progress> |
slider | Range input | <input type="range"> |
switch | Toggle | <input type="checkbox"> |
Rule: Prefer native HTML over ARIA. Use ARIA only when no native element exists for the pattern.
1.12 Label in Name (WCAG 2.5.3 Level A)
When an interactive element has visible text, its accessible name must contain that visible text as a substring (SC 2.5.3). Voice control users (Dragon NaturallySpeaking, macOS Voice Control) speak the visible label to activate controls. If aria-label replaces or contradicts the visible text, voice commands fail.
<!-- Correct: aria-label contains visible text as substring -->
<button aria-label="Delete item from cart">Delete</button>
<!-- Correct: no aria-label needed — visible text is the accessible name -->
<button>Save Changes</button>
<!-- Correct: icon button — no visible text, aria-label is fine -->
<button aria-label="Close dialog">
<svg aria-hidden="true">...</svg>
</button><!-- Incorrect: aria-label overrides visible text with different text -->
<button aria-label="Remove">Delete</button>
<!-- Incorrect: aria-label does not contain visible "Submit" -->
<button aria-label="Proceed to next step">Submit</button>Rule: When visible text is present, aria-label must include that visible text (verbatim, case-insensitively). Prefer no aria-label at all when visible text is sufficient.
---
2. Responsive Design [CRITICAL]
2.1 Mobile-First Approach
Write base styles for the smallest viewport. Layer complexity with min-width media queries.
/* Base: mobile */
.grid {
display: grid;
grid-template-columns: 1fr;
gap: 1rem;
}
/* Tablet */
@media (min-width: 48rem) {
.grid {
grid-template-columns: repeat(2, 1fr);
}
}
/* Desktop */
@media (min-width: 64rem) {
.grid {
grid-template-columns: repeat(3, 1fr);
}
}2.2 Fluid Layouts with Modern CSS Functions
Use clamp(), min(), and max() for fluid sizing without breakpoints.
/* Fluid typography */
h1 {
font-size: clamp(1.75rem, 1.2rem + 2vw, 3rem);
}
/* Fluid spacing */
.section {
padding: clamp(1.5rem, 4vw, 4rem);
}
/* Fluid container */
.container {
width: min(90%, 72rem);
margin-inline: auto;
}2.3 Container Queries
Size components based on their container, not the viewport.
.card-container {
container-type: inline-size;
container-name: card;
}
@container card (min-width: 400px) {
.card {
display: grid;
grid-template-columns: 200px 1fr;
}
}
@container card (min-width: 700px) {
.card {
grid-template-columns: 300px 1fr;
gap: 2rem;
}
}2.4 Content-Based Breakpoints
Set breakpoints where your content breaks, not at device widths. Common starting points:
/* Content-based, not "iPhone" or "iPad" */
@media (min-width: 30rem) { /* ~480px: single column gets cramped */ }
@media (min-width: 48rem) { /* ~768px: room for 2 columns */ }
@media (min-width: 64rem) { /* ~1024px: room for sidebar + content */ }
@media (min-width: 80rem) { /* ~1280px: wide multi-column */ }2.5 Touch Targets
Minimum 44x44 CSS pixels for touch targets (WCAG SC 2.5.5 AAA; SC 2.5.8 requires only 24x24px at AA). Provide at least 24px spacing between adjacent targets.
button, a, input, select, textarea {
min-height: 44px;
min-width: 44px;
}
/* Enlarge tap area without changing visual size */
.icon-button {
position: relative;
width: 24px;
height: 24px;
}
.icon-button::after {
content: "";
position: absolute;
inset: -10px; /* expands clickable area */
}2.6 Viewport Meta Tag
Always include in the document <head>:
<meta name="viewport" content="width=device-width, initial-scale=1">Never use maximum-scale=1 or user-scalable=no -- these break pinch-to-zoom accessibility (SC 1.4.4).
2.7 No Horizontal Scrolling
Content must reflow at 320px width without horizontal scrolling (SC 1.4.10).
/* Prevent overflow */
img, video, iframe, svg {
max-width: 100%;
height: auto;
}
/* Contain long words/URLs */
.prose {
overflow-wrap: break-word;
}
/* Tables: scroll container, not page */
.table-wrapper {
overflow-x: auto;
-webkit-overflow-scrolling: touch;
}---
3. Forms [HIGH]
3.1 Label Every Input
Every input needs a visible, programmatically associated label. See section 1.8.
3.2 Autocomplete Attributes
Use autocomplete for common fields to enable browser autofill (SC 1.3.5).
<input type="text" autocomplete="name" name="full-name">
<input type="email" autocomplete="email" name="email">
<input type="tel" autocomplete="tel" name="phone">
<input type="text" autocomplete="street-address" name="address">
<input type="text" autocomplete="postal-code" name="zip">
<input type="text" autocomplete="cc-name" name="card-name">
<input type="text" autocomplete="cc-number" name="card-number">
<input type="password" autocomplete="new-password" name="password">
<input type="password" autocomplete="current-password" name="current-pw">3.3 Correct Input Types
Use the right type to trigger appropriate mobile keyboards and native validation.
| Type | Use For |
|---|---|
email | Email addresses |
tel | Phone numbers |
url | URLs |
number | Numeric values with spinners (not for phone, zip, card numbers) |
search | Search fields (shows clear button) |
date / time / datetime-local | Temporal values |
password | Passwords (triggers password manager) |
text with inputmode="numeric" | Numeric data without spinners (PINs, zip codes) |
<input type="tel" inputmode="numeric" pattern="[0-9]*" autocomplete="one-time-code">3.4 Inline Validation
Validate on blur (not on every keystroke). Show success and error states.
<div class="field" data-state="error">
<label for="username">Username</label>
<input id="username" type="text" aria-describedby="username-hint username-error" aria-invalid="true">
<p id="username-hint" class="hint">3-20 characters, letters and numbers only</p>
<p id="username-error" class="error" role="alert">Username must be at least 3 characters</p>
</div>.field[data-state="error"] input {
border-color: var(--color-error);
box-shadow: 0 0 0 1px var(--color-error);
}
.field[data-state="error"] .error { display: block; }
.field:not([data-state="error"]) .error { display: none; }3.5 Fieldset and Legend for Groups
Group related inputs with <fieldset> and label the group with <legend>.
<fieldset>
<legend>Shipping Address</legend>
<label for="street">Street</label>
<input id="street" type="text" autocomplete="street-address">
<!-- ... -->
</fieldset>
<fieldset>
<legend>Preferred contact method</legend>
<label><input type="radio" name="contact" value="email"> Email</label>
<label><input type="radio" name="contact" value="phone"> Phone</label>
</fieldset>3.6 Required Field Indication
Indicate required fields visually and programmatically. Use required attribute and visible markers.
<label for="name">
Full name <span aria-hidden="true">*</span>
<span class="sr-only">(required)</span>
</label>
<input id="name" type="text" required autocomplete="name">If most fields are required, indicate which are optional instead.
3.7 Submit Button State
Do not disable the submit button. Instead, validate on submit and show errors.
<!-- Good: always enabled, validate on submit -->
<button type="submit">Create Account</button>
<!-- Bad: disabled button with no explanation -->
<!-- <button type="submit" disabled>Create Account</button> -->Disabled buttons fail to communicate why the user cannot proceed. If you must disable, provide a visible explanation.
3.8 Keep Instructions Near the Field
Place format examples, constraints, and recovery text next to the relevant field via hint and error text. Never explain requirements only once in introductory copy and expect users to remember them later.
---
4. Typography [HIGH]
4.1 Font Stacks
Use system font stacks for performance, or web fonts with proper fallbacks.
/* System font stack */
body {
font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
/* Monospace stack */
code, pre, kbd {
font-family: ui-monospace, "Cascadia Code", "Source Code Pro", Menlo, Consolas, monospace;
}
/* Web font with fallbacks and size-adjust */
@font-face {
font-family: "CustomFont";
src: url("/fonts/custom.woff2") format("woff2");
font-display: swap;
font-weight: 100 900;
}
body {
font-family: "CustomFont", system-ui, sans-serif;
}4.2 Relative Units
Use rem for font sizes and spacing. Use em for component-relative sizing.
html {
font-size: 100%; /* = 16px default, respects user preference */
}
body {
font-size: 1rem; /* 16px */
}
h1 { font-size: 2.5rem; } /* 40px */
h2 { font-size: 2rem; } /* 32px */
h3 { font-size: 1.5rem; } /* 24px */
small { font-size: 0.875rem; } /* 14px */
/* Never: font-size: 16px; (ignores user zoom settings) */4.3 Line Height and Spacing
Body text line height of at least 1.5 (SC 1.4.12). Paragraph spacing at least 2x font size.
body {
line-height: 1.6;
}
h1, h2, h3 {
line-height: 1.2;
}
p + p {
margin-top: 1em;
}4.4 Maximum Line Length
Limit line length to approximately 75 characters for readability.
.prose {
max-width: 75ch;
}
/* Or for a content column */
.content {
max-width: 40rem; /* roughly 65-75ch depending on font */
margin-inline: auto;
}4.5 Typographic Details
Use real quotes, proper dashes, and tabular numbers for data.
/* Smart quotes */
q { quotes: "\201C" "\201D" "\2018" "\2019"; } /* curly double then single */
/* Tabular numbers for aligned data */
.data-table td {
font-variant-numeric: tabular-nums;
}
/* Oldstyle numbers for running prose (optional) */
.prose {
font-variant-numeric: oldstyle-nums;
}
/* Proper list markers */
ul { list-style-type: disc; }
ol { list-style-type: decimal; }4.6 Heading Hierarchy
Use h1 through h6 in order. Never skip levels. One h1 per page.
<!-- Good -->
<h1>Page Title</h1>
<h2>Section</h2>
<h3>Subsection</h3>
<h2>Another Section</h2>
<!-- Bad: skipping h2 -->
<h1>Page Title</h1>
<h3>Subsection</h3> <!-- Where is h2? -->If you need visual styling that differs from the hierarchy, use CSS classes:
<h2 class="text-lg">Visually smaller but semantically h2</h2>---
5. Performance [HIGH]
5.1 Lazy Load Below-Fold Images
Use native lazy loading for images not visible on initial load.
<!-- Above fold: load eagerly, add fetchpriority -->
<img src="hero.webp" alt="Hero image" fetchpriority="high" width="1200" height="600">
<!-- Below fold: lazy load -->
<img src="feature.webp" alt="Feature image" loading="lazy" width="600" height="400">5.2 Explicit Image Dimensions
Always specify width and height to prevent layout shift (CLS).
<img src="photo.webp" alt="Description" width="800" height="600">/* Responsive images with aspect ratio preservation */
img {
max-width: 100%;
height: auto;
}5.3 Resource Hints
Use preconnect for third-party origins and preload for critical resources.
<head>
<!-- Preconnect to critical third-party origins -->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://cdn.example.com" crossorigin>
<!-- Preload critical resources -->
<link rel="preload" href="/fonts/main.woff2" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="/css/critical.css" as="style">
<!-- DNS prefetch for non-critical origins -->
<link rel="dns-prefetch" href="https://analytics.example.com">
</head>5.4 Code Splitting
Load JavaScript only when needed. Use dynamic import() for route-based and component-based splitting.
// Route-based splitting
const routes = {
'/dashboard': () => import('./pages/dashboard.js'),
'/settings': () => import('./pages/settings.js'),
};
// Interaction-based splitting
button.addEventListener('click', async () => {
const { openEditor } = await import('./editor.js');
openEditor();
});5.5 Virtualize Long Lists
For lists exceeding a few hundred items, render only visible rows.
// Concept: virtual scrolling
// Render only items in viewport + buffer
const visibleStart = Math.floor(scrollTop / itemHeight);
const visibleEnd = visibleStart + Math.ceil(containerHeight / itemHeight);
const buffer = 5;
const renderStart = Math.max(0, visibleStart - buffer);
const renderEnd = Math.min(totalItems, visibleEnd + buffer);5.6 Avoid Layout Thrashing
Batch DOM reads and writes. Never interleave them.
// Bad: read-write-read-write (forces synchronous layout)
elements.forEach(el => {
const height = el.offsetHeight; // read
el.style.height = height + 10 + 'px'; // write
});
// Good: batch reads, then batch writes
const heights = elements.map(el => el.offsetHeight); // all reads
elements.forEach((el, i) => {
el.style.height = heights[i] + 10 + 'px'; // all writes
});5.7 Use will-change Sparingly
Only apply will-change to elements that will animate, and remove it after animation completes.
/* Good: scoped and temporary */
.card:hover {
will-change: transform;
}
.card.animating {
will-change: transform, opacity;
}
/* Bad: blanket will-change */
/* * { will-change: transform; } */5.8 Expose Waiting States Promptly
After a user action, acknowledge the new state immediately. If work cannot finish within a brief moment, show progress, skeletons, optimistic UI, or aria-busy feedback instead of leaving the interface unchanged.
---
6. Animation and Motion [MEDIUM]
6.1 Respect prefers-reduced-motion
Always provide a reduced-motion alternative (SC 2.3.3, Level AAA).
/* Define animations normally */
.fade-in {
animation: fadeIn 300ms ease-out;
}
@keyframes fadeIn {
from { opacity: 0; transform: translateY(8px); }
to { opacity: 1; transform: translateY(0); }
}
/* Remove or reduce for users who prefer it */
@media (prefers-reduced-motion: reduce) {
*, *::before, *::after {
animation-duration: 0.01ms !important;
animation-iteration-count: 1 !important;
transition-duration: 0.01ms !important;
scroll-behavior: auto !important;
}
}// Check in JavaScript
const prefersReducedMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches;6.2 Compositor-Friendly Animations
Animate only transform and opacity for smooth 60fps animation. These run on the GPU compositor thread.
/* Good: compositor-only properties */
.slide-in {
transition: transform 200ms ease-out, opacity 200ms ease-out;
}
/* Bad: triggers layout/paint */
.slide-in-bad {
transition: left 200ms, width 200ms, height 200ms;
}6.3 No Flashing Content
Never flash content more than 3 times per second (SC 2.3.1). This can trigger seizures.
6.4 Transitions for State Changes
Use transitions for hover, focus, open/close, and other state changes to provide continuity.
.dropdown {
opacity: 0;
transform: translateY(-4px);
transition: opacity 150ms ease-out, transform 150ms ease-out;
pointer-events: none;
}
.dropdown.open {
opacity: 1;
transform: translateY(0);
pointer-events: auto;
}6.5 Meaningful Motion Only
Animation should communicate state, guide attention, or show spatial relationships. Never animate for decoration alone.
---
7. Dark Mode and Theming [MEDIUM]
7.1 System Preference Detection
@media (prefers-color-scheme: dark) {
:root {
--bg: #0f0f17;
--text: #e4e4ef;
--surface: #1c1c2e;
--border: #2e2e44;
}
}7.2 CSS Custom Properties for Theming
Define all theme values as custom properties. Toggle themes by changing property values.
:root {
color-scheme: light dark;
/* Light theme (default) */
--color-bg: #ffffff;
--color-surface: #f5f5f7;
--color-text-primary: #1a1a2e;
--color-text-secondary: #555770;
--color-border: #d1d1e0;
--color-primary: #2563eb;
--color-primary-text: #ffffff;
--color-error: #dc2626;
--color-success: #16a34a;
}
@media (prefers-color-scheme: dark) {
:root {
--color-bg: #0f0f17;
--color-surface: #1c1c2e;
--color-text-primary: #e4e4ef;
--color-text-secondary: #a0a0b8;
--color-border: #2e2e44;
--color-primary: #60a5fa;
--color-primary-text: #0f0f17;
--color-error: #f87171;
--color-success: #4ade80;
}
}7.3 Color-Scheme Meta Tag
Tell the browser about supported color schemes for native UI elements (scrollbars, form controls).
<meta name="color-scheme" content="light dark">7.4 Maintain Contrast in Both Modes
Verify contrast ratios in both light and dark modes. Dark mode often suffers from low-contrast text on dark surfaces.
7.5 Adaptive Images
Provide appropriate images for light and dark contexts.
<picture>
<source srcset="logo-dark.svg" media="(prefers-color-scheme: dark)">
<img src="logo-light.svg" alt="Company logo">
</picture>/* Or use CSS filter for simple cases */
@media (prefers-color-scheme: dark) {
.decorative-img {
filter: brightness(0.9) contrast(1.1);
}
}7.6 Respect prefers-contrast
Honor the user's contrast preference using @media (prefers-contrast: more) and @media (prefers-contrast: forced). prefers-contrast: more responds to macOS/iOS "Increase Contrast" in System Settings; prefers-contrast: forced responds to Windows High Contrast Mode — a distinct OS feature that overrides colors entirely.
/* Default theme */
:root {
--color-text: #555770;
--color-border: #d1d1e0;
--color-bg: #ffffff;
}
/* High contrast mode: stronger text and border colors */
@media (prefers-contrast: more) {
:root {
--color-text: #1a1a2e; /* Darker text for higher ratio */
--color-border: #1a1a2e; /* Stronger borders */
--color-bg: #ffffff;
}
/* Ensure interactive elements are clearly delineated */
button, input, select, textarea {
border: 2px solid currentColor;
}
}
/* Forced colors (Windows High Contrast mode) */
@media (prefers-contrast: forced) {
/* Use system color keywords to respect OS color palette */
:root {
--color-text: ButtonText;
--color-bg: ButtonFace;
--color-border: ButtonBorder;
}
}---
8. Navigation and State [MEDIUM]
8.1 URL Reflects State
Every meaningful view should have a unique URL. Users should be able to bookmark, share, and reload any state.
// Update URL without full page reload
function updateFilters(filters) {
const params = new URLSearchParams(filters);
history.pushState(null, '', `?${params}`);
renderResults(filters);
}
// Restore state from URL on load
const params = new URLSearchParams(location.search);
const initialFilters = Object.fromEntries(params);8.2 Browser Back/Forward
Handle popstate to support browser navigation.
window.addEventListener('popstate', () => {
const params = new URLSearchParams(location.search);
renderResults(Object.fromEntries(params));
});8.3 Active Navigation States
Indicate the current page or section in navigation. Use aria-current="page" for the active link.
<nav aria-label="Main">
<a href="/" aria-current="page">Home</a>
<a href="/products">Products</a>
<a href="/about">About</a>
</nav>[aria-current="page"] {
font-weight: 700;
border-bottom: 2px solid var(--color-primary);
}8.4 Breadcrumbs
Provide breadcrumbs for sites with deep hierarchies.
<nav aria-label="Breadcrumb">
<ol>
<li><a href="/">Home</a></li>
<li><a href="/products">Products</a></li>
<li><a href="/products/widgets" aria-current="page">Widgets</a></li>
</ol>
</nav>8.5 Scroll Restoration
Manage scroll position for SPA navigation.
// Disable browser auto-restoration for manual control
if ('scrollRestoration' in history) {
history.scrollRestoration = 'manual';
}
// Save scroll position before navigation
function saveScrollPosition() {
sessionStorage.setItem(`scroll-${location.pathname}`, window.scrollY);
}
// Restore on back/forward
window.addEventListener('popstate', () => {
const saved = sessionStorage.getItem(`scroll-${location.pathname}`);
if (saved) {
requestAnimationFrame(() => window.scrollTo(0, parseInt(saved)));
}
});---
9. Touch and Interaction [MEDIUM]
9.1 Touch-Action for Scroll Control
Use touch-action to control gesture behavior on interactive elements.
/* Allow only vertical scrolling (disable horizontal pan and pinch-zoom) */
.vertical-scroll {
touch-action: pan-y;
}
/* Carousel: horizontal scroll only */
.carousel {
touch-action: pan-x;
}
/* Canvas/map: disable all browser gestures */
.canvas {
touch-action: none;
}9.2 Tap Highlight
Control the tap highlight on mobile WebKit browsers.
button, a {
-webkit-tap-highlight-color: transparent;
}9.3 Hover and Focus Parity
Every hover interaction must also work with keyboard focus.
/* Always pair :hover with :focus-visible */
.card:hover,
.card:focus-visible {
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
transform: translateY(-2px);
}9.4 No Hover-Only Interactions
Never hide essential functionality behind hover. Touch devices have no hover state.
/* Bad: content only accessible on hover */
/* .tooltip { display: none; }
.trigger:hover .tooltip { display: block; } */
/* Good: works with focus and click too */
.trigger:hover .tooltip,
.trigger:focus-within .tooltip,
.tooltip:focus-within {
display: block;
}9.5 Scroll Snap for Carousels
Use CSS scroll snap for card carousels and horizontal lists.
.carousel {
display: flex;
overflow-x: auto;
scroll-snap-type: x mandatory;
gap: 1rem;
scroll-padding: 1rem;
}
.carousel > .slide {
scroll-snap-align: start;
flex: 0 0 min(85%, 400px);
}---
10. Internationalization [MEDIUM]
10.1 dir and lang Attributes
Set lang on the <html> element. Use dir="auto" for user-generated content.
<html lang="en" dir="ltr">
<!-- User-generated content: let browser detect direction -->
<p dir="auto">User-submitted text here</p>
<!-- Explicit override for known RTL content -->
<blockquote lang="ar" dir="rtl">...</blockquote>10.2 Intl APIs for Formatting
Use the Intl API for locale-aware formatting. Never hard-code date or number formats.
// Dates
new Intl.DateTimeFormat('en-US', { dateStyle: 'long' }).format(date);
// "January 15, 2026"
// Numbers
new Intl.NumberFormat('de-DE', { style: 'currency', currency: 'EUR' }).format(1234.56);
// "1.234,56 EUR"
// Relative time
new Intl.RelativeTimeFormat('en', { numeric: 'auto' }).format(-1, 'day');
// "yesterday"
// Lists
new Intl.ListFormat('en', { style: 'long', type: 'conjunction' }).format(['a', 'b', 'c']);
// "a, b, and c"
// Plurals
const pr = new Intl.PluralRules('en');
const suffixes = { one: 'st', two: 'nd', few: 'rd', other: 'th' };
function ordinal(n) { return `${n}${suffixes[pr.select(n)]}`; }10.3 Avoid Text in Images
Text in images cannot be translated, resized, or read by screen readers. Use HTML/CSS text with background images when a styled text overlay is needed.
10.4 CSS Logical Properties
Use logical properties instead of physical ones to support both LTR and RTL layouts.
/* Physical (breaks in RTL) */
/* margin-left: 1rem; padding-right: 2rem; border-left: 1px solid; */
/* Logical (works in LTR and RTL) */
.sidebar {
margin-inline-start: 1rem;
padding-inline-end: 2rem;
border-inline-start: 1px solid var(--color-border);
}
.stack > * + * {
margin-block-start: 1rem;
}
/* Logical shorthands */
.box {
margin-inline: auto; /* left + right */
padding-block: 2rem; /* top + bottom */
inset-inline-start: 0; /* left in LTR, right in RTL */
border-start-start-radius: 8px; /* top-left in LTR, top-right in RTL */
}| Physical | Logical |
|---|---|
left / right | inline-start / inline-end |
top / bottom | block-start / block-end |
margin-left | margin-inline-start |
padding-right | padding-inline-end |
border-top-left-radius | border-start-start-radius |
width | inline-size |
height | block-size |
text-align: left | text-align: start |
10.5 RTL Layout Support
Test layouts in RTL mode. Flexbox and Grid handle RTL automatically with logical properties.
/* This layout works in both LTR and RTL without changes */
.layout {
display: flex;
gap: 1rem;
}
/* Icons that indicate direction need flipping */
[dir="rtl"] .arrow-icon {
transform: scaleX(-1);
}---
11. Progressive Web Apps [MEDIUM]
PWAs allow web apps to be installed and run offline. When building an installable web app, the following rules ensure the experience is consistent and reliable.
11.1 Provide a Complete Web App Manifest
Include a manifest.json linked from <head> with all required fields for installability. Missing fields silently prevent install prompts.
<link rel="manifest" href="/manifest.json">{
"name": "My App",
"short_name": "App",
"start_url": "/",
"display": "standalone",
"icons": [
{ "src": "/icons/icon-192.png", "sizes": "192x192", "type": "image/png" },
{ "src": "/icons/icon-512.png", "sizes": "512x512", "type": "image/png" }
]
}Incorrect:
{
"name": "My App"
// Missing start_url, display, and icons — app is not installable
}11.2 Set theme_color and background_color
theme_color tints the browser chrome and the OS task switcher. background_color fills the splash screen before the app loads. Both must match your brand colors.
{
"theme_color": "#1a73e8",
"background_color": "#ffffff"
}11.3 Register a Service Worker for Offline Support
A service worker is required for installability and offline capability. Cache critical assets on install; respond from cache when offline.
// In your main entry point
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('/sw.js');
}// sw.js — cache on install, serve from cache when offline
const CACHE = 'v1';
const PRECACHE = ['/', '/index.html', '/app.js', '/app.css'];
self.addEventListener('install', e =>
e.waitUntil(caches.open(CACHE).then(c => c.addAll(PRECACHE)))
);
self.addEventListener('fetch', e =>
e.respondWith(
caches.match(e.request).then(hit => hit ?? fetch(e.request))
)
);11.4 Meet Installability Criteria
For the browser install prompt to appear: the app must be served over HTTPS, have a registered service worker with a fetch handler, and include a manifest with name, icons, start_url, and display: standalone (or fullscreen/minimal-ui).
11.5 Use display Mode Appropriately
| Value | Use When |
|---|---|
standalone | App replaces browser UI; most common choice |
fullscreen | Games or media apps needing the entire screen |
minimal-ui | Retain minimal browser controls (back, reload) |
browser | No installation behavior; opens in browser tab |
---
Evaluation Checklist
Use this checklist when building or reviewing web interfaces.
Accessibility
- [ ] All images have appropriate
alttext - [ ] Color contrast meets 4.5:1 (text) and 3:1 (UI components)
- [ ] All interactive elements are keyboard accessible
- [ ] Focus indicators are visible (3:1 contrast, 2px minimum perimeter)
- [ ] Skip navigation link is present
- [ ] Form inputs have associated labels
- [ ] Error messages are linked to their inputs
- [ ] Dynamic content updates use ARIA live regions
- [ ] No content flashes more than 3 times per second
- [ ] Page has proper heading hierarchy (h1-h6, no skips)
- [ ] Landmarks are used correctly (main, nav, header, footer)
Responsive
- [ ] No horizontal scrolling at 320px width
- [ ] Touch targets are at least 44x44px
- [ ] Viewport meta tag is present (no user-scalable=no)
- [ ] Layout works on mobile, tablet, and desktop
- [ ] Text is readable without zooming on mobile
Forms
- [ ] All inputs have visible labels
- [ ] Autocomplete attributes are set for common fields
- [ ] Correct input types trigger correct mobile keyboards
- [ ] Error messages are clear and specific
- [ ] Required fields are indicated
- [ ] Submit button is not disabled
Performance
- [ ] Below-fold images use
loading="lazy" - [ ] Images have explicit
widthandheight - [ ] Critical fonts are preloaded
- [ ] Third-party origins use
preconnect - [ ] Large JS bundles are code-split
Motion and Theming
- [ ]
prefers-reduced-motionis respected - [ ] Animations use only
transformandopacity - [ ] Dark mode maintains contrast ratios
- [ ]
color-schememeta tag is present - [ ] Theme uses CSS custom properties
- [ ]
prefers-contrast: moreincreases text and border contrast - [ ]
prefers-contrast: forceduses system color keywords
Internationalization
- [ ]
langattribute on<html> - [ ] CSS logical properties used (not physical)
- [ ] Dates/numbers formatted with Intl APIs
- [ ] No text embedded in images
- [ ] Layout tested in RTL mode
Progressive Web App
- [ ] Web App Manifest linked from
<head>withname,icons,start_url, anddisplay - [ ]
theme_colorandbackground_colormatch brand palette - [ ] Service worker registered with a
fetchhandler for offline support - [ ] App served over HTTPS
---
Common Anti-Patterns
| Anti-Pattern | Fix |
|---|---|
<div onclick="..."> | Use <button> |
outline: none without replacement | Use :focus-visible with custom outline |
placeholder as label | Add a <label> element |
tabindex="5" | Use tabindex="0" or natural order |
user-scalable=no | Remove it |
font-size: 12px | Use font-size: 0.75rem |
Animating width/height/top/left | Animate transform and opacity |
| Disabling submit button | Validate on submit, show errors |
| Color alone for status | Add icon, text, or pattern |
margin-left / padding-right | Use margin-inline-start / padding-inline-end |
<img> without dimensions | Add width and height attributes |
| Hover-only disclosure | Add :focus-within and click handler |
---
Credits & Attribution
This skill is based on the excellent work by [ehmo](https://github.com/ehmo/platform-design-skills).
Original repository: https://github.com/ehmo/platform-design-skills
Special thanks to ehmo for their generous open-source contributions, which helped shape this skill collection. Adapted by webconsulting.at for this skill collection
Web Platform Design Skills
Purpose
Framework-agnostic web design and accessibility guidelines based on WCAG 2.2, MDN Web Docs, and modern web platform standards.
File Structure
web/
metadata.json # Version, references, abstract
SKILL.md # Full guidelines (load this)
AGENTS.md # This file
rules/
_sections.md # Sectioned rules for selective loadingUsage
- Load
SKILL.mdfor complete guidelines when building or reviewing web UI. - Load
rules/_sections.mdfor individual category rules when working on a specific concern (e.g., only accessibility, only forms).
When to Apply
- Building HTML/CSS/JS interfaces
- Auditing accessibility or WCAG compliance
- Implementing responsive layouts
- Reviewing web UI pull requests
- Optimizing web performance
- Adding dark mode or theming
- Internationalizing web content
Priority Levels
| Level | Categories |
|---|---|
| CRITICAL | Accessibility/WCAG, Responsive Design |
| HIGH | Forms, Typography, Performance |
| MEDIUM | Animation, Dark Mode, Navigation, Touch, i18n, Progressive Web Apps |
Conventions
- Rules use imperative voice ("Use semantic HTML", not "You should use").
- Code examples are vanilla HTML/CSS/JS unless noted.
- WCAG success criteria referenced as (SC x.x.x).
- Priority in brackets: [CRITICAL], [HIGH], [MEDIUM].
Never Do
- Never use
<div onclick>when<button>exists — use semantic HTML - Never set
maximum-scale=1oruser-scalable=noin the viewport meta tag - Never rely on color alone to convey information — pair with text or icons
- Never use placeholder text as the only label for a form input
- Never build interactive elements that are only keyboard-accessible via
tabindex > 0 - Never omit
altattributes on images — usealt=""for decorative images - Never animate content that flashes more than 3 times per second (seizure risk)
- Never trap keyboard focus inside a component without providing a documented escape
- Never use
<table>for layout — tables are for tabular data only - Never set
font-sizeinpxon body text — useremso user preferences apply
{
"version": "1.0.0",
"organization": "Platform Design Skills",
"date": "February 2026",
"abstract": "Web platform design and accessibility guidelines. 70+ rules across 11 categories covering WCAG 2.2 accessibility, responsive design, semantic HTML, performance, forms, animations, typography, dark mode, internationalization, and Progressive Web Apps. Framework-agnostic with HTML/CSS/JS examples.",
"references": [
"https://www.w3.org/WAI/WCAG22/quickref/",
"https://developer.mozilla.org/en-US/docs/Web",
"https://web.dev",
"https://www.a11yproject.com"
]
}
Web Platform Design Rules (Sectioned)
Load individual sections as needed. Each section is self-contained.
---
<!-- SECTION: accessibility -->
Accessibility / WCAG [CRITICAL]
Rules
1. Use semantic HTML elements. Use <main>, <nav>, <header>, <footer>, <article>, <section>, <aside>, <figure>, <dialog>, <details> for their intended purpose. Never use <div onclick> when <button> exists.
2. Add ARIA labels to interactive elements without visible text. Icon buttons need aria-label. Groups need aria-labelledby. Do not add ARIA when visible text already provides the name.
3. Ensure keyboard navigation. All interactive elements reachable via Tab. Custom widgets need tabindex="0" and keydown handlers. Trap focus inside modals. Never use tabindex > 0.
4. Provide visible focus indicators. Use :focus-visible with 3px outline and 2px offset. WCAG 2.2 requires minimum 2px perimeter area with 3:1 contrast.
5. Include skip navigation links. Add <a href="#main-content" class="skip-link">Skip to main content</a> before the nav. Visually hidden until focused.
6. Write appropriate alt text. Informative images: describe content. Decorative images: alt="". Functional images: describe the action. Complex images: short alt + linked long description.
7. Meet color contrast ratios. Normal text: 4.5:1. Large text (>=24px or >=18.66px bold): 3:1. UI components and graphics: 3:1. Never rely on color alone.
8. Associate labels with form inputs. Use <label for="id"> or wrap input in <label>. Never use placeholder as the only label.
9. Identify errors in text and link to inputs. Use aria-describedby or aria-errormessage with aria-invalid="true". Error text must describe how to fix the problem.
10. Use ARIA live regions for dynamic updates. aria-live="polite" for non-urgent updates. role="alert" for time-sensitive messages. role="status" for status messages.
11. Prefer native HTML over ARIA roles. Use <button> not <div role="button">. Use <nav> not <div role="navigation">. ARIA is a supplement, not a replacement.
12. Accessible name must contain visible text (SC 2.5.3). When an element has visible text, its accessible name must include that text as a substring. Do not use aria-label that replaces visible text with different text — voice control users speak the visible label to activate controls.
<!-- /SECTION: accessibility -->
---
<!-- SECTION: responsive -->
Responsive Design [CRITICAL]
Rules
1. Build mobile-first. Base styles for smallest viewport. Add complexity with min-width media queries.
2. Use fluid sizing with `clamp()`, `min()`, `max()`. Fluid typography: font-size: clamp(1.75rem, 1.2rem + 2vw, 3rem). Fluid containers: width: min(90%, 72rem).
3. Use container queries for component-level responsiveness. Set container-type: inline-size on wrappers. Use @container for layout changes based on available space.
4. Set breakpoints at content, not device widths. Break where your layout breaks. Common starting points: 30rem, 48rem, 64rem, 80rem.
5. Ensure touch targets are 44x44px minimum. Expand small icons with ::after pseudo-element and negative inset. Maintain 24px spacing between adjacent targets.
6. Include viewport meta tag. <meta name="viewport" content="width=device-width, initial-scale=1">. Never use maximum-scale=1 or user-scalable=no.
7. Prevent horizontal scrolling. Set max-width: 100%; height: auto on images/video/iframes. Use overflow-wrap: break-word for long text. Wrap tables in overflow-x: auto container.
<!-- /SECTION: responsive -->
---
<!-- SECTION: forms -->
Forms [HIGH]
Rules
1. Label every input. Use <label for="id"> with matching id on the input. Every field needs a visible, programmatically associated label.
2. Set autocomplete attributes. Use autocomplete="email", autocomplete="tel", autocomplete="name", autocomplete="street-address", etc. Required by WCAG SC 1.3.5.
3. Use correct input types. type="email" for email, type="tel" for phone, type="url" for URLs, inputmode="numeric" for numeric data without spinners.
4. Validate inline on blur. Show errors after the user leaves a field, not on every keystroke. Use aria-invalid and aria-describedby to link errors.
5. Group related fields with fieldset/legend. Radio groups, checkbox groups, and address blocks belong in <fieldset> with a <legend>.
6. Indicate required fields. Use required attribute. Show a visible marker (asterisk or "(required)" text). If most fields are required, indicate optional fields instead.
7. Keep submit buttons enabled. Validate on submit and show errors. Disabled buttons fail to explain why the user cannot proceed.
8. Keep instructions near the field. Put examples, constraints, and recovery text next to the relevant input so users do not have to remember guidance from earlier copy.
<!-- /SECTION: forms -->
---
<!-- SECTION: typography -->
Typography [HIGH]
Rules
1. Use system font stacks or web fonts with fallbacks. System: font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif. Web fonts: add font-display: swap.
2. Use relative units. rem for font sizes and spacing. em for component-relative sizing. Never set font-size in px on body text.
3. Set body line height to at least 1.5. Headings can use 1.2. Paragraph spacing at least 2x font size. Required by WCAG SC 1.4.12.
4. Limit line length to ~75 characters. Use max-width: 75ch or max-width: 40rem on prose containers.
5. Use proper typographic details. Curly quotes via CSS quotes property. Tabular numbers (font-variant-numeric: tabular-nums) for data columns.
6. Maintain heading hierarchy. h1 through h6 in order, no skipping. One h1 per page. Style headings with classes if visual size differs from semantic level.
<!-- /SECTION: typography -->
---
<!-- SECTION: performance -->
Performance [HIGH]
Rules
1. Lazy load below-fold images. Use loading="lazy". Above-fold hero images get fetchpriority="high".
2. Set explicit image dimensions. Add width and height attributes to prevent Cumulative Layout Shift (CLS).
3. Use resource hints. <link rel="preconnect"> for third-party origins. <link rel="preload"> for critical fonts and CSS. <link rel="dns-prefetch"> for non-critical origins.
4. Code-split JavaScript. Use dynamic import() for route-based and interaction-based splitting. Load heavy libraries only when needed.
5. Virtualize long lists. Render only visible rows plus a small buffer for lists exceeding a few hundred items.
6. Avoid layout thrashing. Batch all DOM reads, then batch all DOM writes. Never interleave reads and writes in a loop.
7. Use `will-change` sparingly. Apply only to elements that will animate. Remove after animation completes. Never apply globally.
8. Expose waiting states promptly. After user input, acknowledge the new state immediately. If work will take longer than a brief moment, show progress, skeletons, optimistic UI, or aria-busy.
<!-- /SECTION: performance -->
---
<!-- SECTION: animation -->
Animation and Motion [MEDIUM]
Rules
1. Respect `prefers-reduced-motion`. Wrap all animations in a media query check. Set animation-duration: 0.01ms and transition-duration: 0.01ms for reduced motion preference.
2. Animate only compositor-friendly properties. Use transform and opacity. Avoid animating width, height, top, left, margin, or padding.
3. No flashing content above 3Hz. Content that flashes more than 3 times per second can trigger seizures. WCAG SC 2.3.1.
4. Use transitions for state changes. Hover, focus, open/close, and visibility changes should transition smoothly (150-300ms).
5. Motion must be meaningful. Animate to communicate state, guide attention, or show spatial relationships. Never animate purely for decoration.
<!-- /SECTION: animation -->
---
<!-- SECTION: dark-mode -->
Dark Mode and Theming [MEDIUM]
Rules
1. Detect system preference. Use @media (prefers-color-scheme: dark) to switch theme tokens.
2. Define themes with CSS custom properties. All colors, shadows, and surfaces as --custom-properties. Toggle entire themes by redefining variables.
3. Set the `color-scheme` meta tag. <meta name="color-scheme" content="light dark">. Also set color-scheme: light dark in CSS for native form controls.
4. Verify contrast in both modes. Dark mode commonly fails contrast on secondary text and disabled states. Re-check all ratios.
5. Adapt images to theme. Use <picture> with media="(prefers-color-scheme: dark)" for alternate assets. Use filter: brightness() for simple adjustments.
6. Respect `prefers-contrast`. Use @media (prefers-contrast: more) to increase text and border contrast for users with OS-level "Increase Contrast" enabled. Use @media (prefers-contrast: forced) with system color keywords (ButtonText, ButtonFace, ButtonBorder) for Windows High Contrast mode.
<!-- /SECTION: dark-mode -->
---
<!-- SECTION: navigation -->
Navigation and State [MEDIUM]
Rules
1. URL reflects state. Every meaningful view has a unique URL. Use URLSearchParams and history.pushState for filters, tabs, and pagination.
2. Support browser back/forward. Handle popstate events to restore state from the URL.
3. Mark active navigation items. Use aria-current="page" on the active link. Style with [aria-current="page"] selector.
4. Add breadcrumbs for deep hierarchies. Use <nav aria-label="Breadcrumb"> with an ordered list. Mark current page with aria-current="page".
5. Manage scroll restoration. Set history.scrollRestoration = 'manual' in SPAs. Save and restore scroll position on navigation.
<!-- /SECTION: navigation -->
---
<!-- SECTION: touch -->
Touch and Interaction [MEDIUM]
Rules
1. Use `touch-action` for scroll control. pan-y for vertical-only scroll areas. pan-x for carousels. none for canvas/map elements.
2. Disable tap highlight. Set -webkit-tap-highlight-color: transparent on buttons and links; provide your own active state instead.
3. Pair hover with focus-visible. Every :hover style must have an equivalent :focus-visible style.
4. No hover-only interactions. Tooltips and dropdowns must work with :focus-within and click/tap. Touch devices have no hover state.
5. Use CSS scroll snap for carousels. scroll-snap-type: x mandatory on the container. scroll-snap-align: start on each item.
<!-- /SECTION: touch -->
---
<!-- SECTION: i18n -->
Internationalization [MEDIUM]
Rules
1. Set `lang` and `dir` attributes. Set lang on <html> using BCP 47 language tags (en, fr, ar, zh-Hans). Override with lang on elements containing different-language content. Use dir="auto" for user-generated content; use dir="rtl" or dir="ltr" when direction is known.
2. Format with Intl APIs. Intl.DateTimeFormat for dates. Intl.NumberFormat for numbers and currency. Intl.RelativeTimeFormat for relative time. Intl.ListFormat for lists.
3. Avoid text in images. Text in images cannot be translated, resized, or read by screen readers.
4. Use CSS logical properties. margin-inline-start not margin-left. padding-block-end not padding-bottom. inset-inline-start not left. text-align: start not text-align: left.
5. Support RTL layouts. Test in RTL mode. Flip directional icons with transform: scaleX(-1) in [dir="rtl"]. Flexbox and Grid handle flow reversal automatically with logical properties.
<!-- /SECTION: i18n -->
---
<!-- SECTION: pwa -->
Progressive Web Apps [MEDIUM]
Rules
1. Provide a complete Web App Manifest. Link manifest.json from <head>. Required fields: name, short_name, start_url, display, and icons (192px and 512px PNG). Missing fields prevent the install prompt.
2. Set `theme_color` and `background_color`. theme_color tints OS chrome and the task switcher. background_color fills the splash screen. Match both to your brand palette.
3. Register a service worker with a fetch handler. Required for installability. Cache critical assets on install; serve from cache when offline. Use a fetch event listener to intercept requests.
4. Meet all installability criteria. HTTPS is required. The service worker must have a fetch handler. The manifest must include name, icons, start_url, and display: standalone (or fullscreen/minimal-ui).
5. Choose `display` mode intentionally. Use standalone for most apps (replaces browser UI). Use fullscreen for games/media. Use minimal-ui to retain minimal browser controls. Avoid browser for installed app experiences.
<!-- /SECTION: pwa -->
---
Quick Reference: Semantic HTML Elements
| Element | Use For | Replaces |
|---|---|---|
<button> | Actions, toggles | <div onclick>, <a href="#"> |
<a href> | Navigation to URLs | <span onclick> |
<nav> | Navigation blocks | <div class="nav"> |
<main> | Primary content | <div class="main"> |
<header> | Page/section header | <div class="header"> |
<footer> | Page/section footer | <div class="footer"> |
<article> | Independent content | <div class="article"> |
<section> | Thematic group | <div class="section"> |
<aside> | Side content | <div class="sidebar"> |
<dialog> | Modal dialogs | <div class="modal"> |
<details>/<summary> | Disclosure | Custom accordion JS |
<fieldset>/<legend> | Form groups | <div class="group"> |
<figure>/<figcaption> | Figures with captions | <div class="image-wrap"> |
<time> | Dates and times | <span class="date"> |
<search> | Search landmark | <div role="search"> |
<output> | Calculation result | <span class="result"> |
<progress> | Progress indicator | <div class="progress"> |
<meter> | Scalar measurement | <div class="gauge"> |
Quick Reference: Common ARIA Patterns
| Pattern | Key Attributes |
|---|---|
| Tabs | role="tablist", role="tab", role="tabpanel", aria-selected, aria-controls |
| Accordion | <button aria-expanded>, aria-controls, <div role="region"> |
| Modal | <dialog> or role="dialog", aria-modal="true", aria-labelledby |
| Combobox | role="combobox", aria-expanded, aria-controls, aria-activedescendant |
| Alert | role="alert" (assertive) or role="status" (polite) |
| Tooltip | role="tooltip", aria-describedby on trigger |
| Menu | role="menu", role="menuitem", aria-haspopup |
| Tree | role="tree", role="treeitem", aria-expanded |
| Breadcrumb | <nav aria-label="Breadcrumb">, aria-current="page" |
| Live region | aria-live="polite" or aria-live="assertive", aria-atomic |