Skip to content

Instantly share code, notes, and snippets.

View davatron5000's full-sized avatar
🚀
Making Luro

Dave Rupert davatron5000

🚀
Making Luro
View GitHub Profile
layout title description categories
post
How-to: Future proof your accessibility efforts.
Ways to make your accessibility effort as future proof as possible.
How-tos

How-to: Use role="application"

Summary: Use role="application" very sparingly, if at all.

NEVER use role="application" on a widely containing element such as <body> if your page consists mostly of traditional widgets or page elements such as links that the user does not have to interact with in focus mode. Using role="application" unnecessarily can cause huge headaches for any assistive technology user trying to use your site/application. Only put it on the <body> element if your page consists solely of a widget or set of widgets that all need the focus mode[^focusmode] to be turned on.

Do Use

  1. Use if your page has no resemblance to a classic document in roughly over 90% of its content
  2. Use clear labels within your application

MYTH: Screen readers don't use JavaScript

A common misconception among web developers is that screen readers only read the non-JavaScript page. Due to this misconception, we sometimes assume it's unnecessary to make JavaScript apps and other functionality accessible. This is categorically false.

According to a May 2012 survey conducted by WebAIM, 98.6% of screen reader users have JavaScript enabled.

Javascript enabled: 98.6% vs. Javascript disbaled: 1.4%

Be sure to make efforts to ensure that the JavaScript functionality (apps, custom UI controls, forms, etc) within your site is accessible. It could be as simple as opting for native links and form inputs instead of custom scripted form elements.

How-to: Use TITLE attributes

Short answer: Don't use them, except in special circumstances.

HTML title attributes are often perceived as an accessibility (and SEO) bonus, but the opposite is true. For screen reader users the content included inside of the title attribute is typically unncessary, redundant, and possibly not even used. Conversely, content being put in the title attribute is being hidden from the (probable) majority of your users. If information is being hidden from the majority of your users, then it's probably not necessary.

There are a few times when using a title attribute is appropriate:

  • For <frame> and <iframe> elements
  • For providing a label when a text label would be redundant

Quick Tip: WAVE your website

How-to: Have Great Color Contrast

2 benefits

  • Text is readable by people with low vision.
  • Luminosity difference aids color blindness.

Notable ratios

  • 4.5:1 for small text
  • 3.0:1 for large text (18pt/14pt Bold) (24px/19px Bold)
  • 2.5:1 for links

Sample Form

<label for="email">Email</label>
<input id="email" type="email" aria-required="true" />

Form validation

Quick Tip: A placeholder is not a label

Form input placeholder attributes are helpful for providing tips to (sighted) users on the format of content required. Often times, due to design decisions, a placeholder is used to replace a more semantic label element. Unfortunately, accessible placeholder browser support isn't complete and placeholder often lack sufficient color contrast.

  1. Redesign to include a proper label
  2. Use aria-label or aria-labelledby to provide assistive text
  3. Visually hide label elements (in an accessible manner)

While we're paying attention to our placeholder text, be sure to add better contrast to you placeholder text:


layout: post title: "Introducing TimeJump" tldr: "Drop-in deep linking for audio and video podcasts." published: true head: | <style type="text/css"> body { position:relative;