Paj Digital Labs
All articles
Web Design & Engineering

Accessible by Default: The Front-End Habits That Fix Most Problems

Accessibility is not a final audit; it is a set of habits. Semantic HTML, visible focus, real labels and honest contrast fix the majority of issues before anyone runs a checker.

Paj Digital Labs 2 min read
Web design workspace with desktop and laptop displays
Editorial illustration · Web Design & Engineering

Most accessibility problems are not exotic. They are buttons made of divs, inputs with no labels, focus outlines removed for aesthetics, and grey text on a slightly lighter grey background. Fix those habits and you resolve the majority of issues before an audit ever happens.

Use the right element

Native HTML elements come with keyboard support, focus behaviour and screen reader semantics built in.

html
<!-- Don't -->
<div class=class="text-code-string">"btn" onclick=class="text-code-string">"save()">Save</div>

<!-- Do -->
<button type=class="text-code-string">"button" onclick=class="text-code-string">"save()">Save</button>

The div version is not focusable, does not respond to Enter or Space, and is announced as plain text. Rebuilding all of that with ARIA and key handlers is more code and usually still incomplete.

Rule of thumb: links go somewhere, buttons do something. Never use a link with href="#" as a button.

Every input needs a label

Placeholder text is not a label. It disappears when the user types and is often too low-contrast to read.

html
<label for=class="text-code-string">"email">Email address</label>
<input id=class="text-code-string">"email" type=class="text-code-string">"email" autocomplete=class="text-code-string">"email" />

The correct type and autocomplete values also help mobile keyboards and password managers — accessibility and usability improve together.

Keep focus visible

Removing focus outlines makes a site unusable for keyboard users. Style them instead:

css
:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}

:focus-visible shows the outline for keyboard navigation without showing it on every mouse click, which removes the usual design objection.

Contrast is not optional

Body text should meet at least a 4.5:1 contrast ratio against its background; large text 3:1. Light grey metadata text is the most common failure on editorial sites. Check your design tokens once and every component inherits the fix.

Headings form an outline

Screen reader users often navigate by headings. Use one h1 per page, then h2 and h3 in a logical order. Choose heading levels by structure, and style them with CSS — never pick h4 because it looks the right size.

Images need meaningful alt text

| Image type | Alt text | |---|---| | Informative | Describe what matters: "Graph showing response time dropping after caching" | | Decorative | Empty: alt="" | | Functional (icon button) | Describe the action: "Search" |

Icon-only buttons need an accessible name, via visible text, aria-label or visually hidden text.

Manage focus in dynamic UI

When a dialog opens, move focus into it, trap focus while it is open, and return focus to the trigger when it closes. Close it with Escape. Well-built component libraries handle this for you — another reason to use them rather than hand-rolling modals.

Respect motion preferences

css
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

Test the basics yourself

  • Tab through every page. Can you reach and use everything? Can you see where you are?
  • Zoom to 200%. Does the layout still work?
  • Run an automated checker. It catches roughly a third of issues — useful, not sufficient.
  • Try a screen reader on your key flows at least once.

Accessibility done as habit costs almost nothing. Done as a pre-launch audit, it costs weeks. The habits also make your site faster to use for everyone, which is the point.

Paj Digital Labs

The engineering journal of Paj Digital Solutions — hosting, server infrastructure and web engineering, written by the people who run the servers.

Related reading