Skip to content

Instantly share code, notes, and snippets.

@ChrisBAshton
Last active December 9, 2018 15:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ChrisBAshton/e6f4a4fe5ee25abb099c44cd26a8e2c6 to your computer and use it in GitHub Desktop.
Save ChrisBAshton/e6f4a4fe5ee25abb099c44cd26a8e2c6 to your computer and use it in GitHub Desktop.
Screen reader gists
<label>
Important: We can only hold details of one trip at a time.
<input type="checkbox" /> Tick to confirm you have read this. *
</label>
<figure>
<img src="/havasu.jpg" alt="Aerial view of Lake Havasu on a sunny day" />
<figcaption>Lake Havasu was created after the completion of the Parker Dam in 1938, which held back the Colorado River</figcaption>
</figure>
<style>
.off-screen {
clip: rect(0 0 0 0);
clip-path: inset(100%);
height: 1px;
overflow: hidden;
position: absolute;
white-space: nowrap;
width: 1px;
}
</style>
<a href="/tweets/123/like">
<span class="off-screen">1,887 users like this tweet. Click to like</span>
<span aria-hidden="true">1,887</span>
</a>
<div role="region" aria-live="polite" class="off-screen" id="search-status"></div>
<form id="search-form">
<label>
<span class="off-screen">Search for a video</span>
<input type="text" />
</label>
<input type="submit" value="Search" />
</form>
<script>
document.getElementById('search-form').addEventListener('submit', function (e) {
e.preventDefault();
ajaxSearchResults(); // not defined here, for brevity
document.getElementById('search-status').textContent = 'Search submitted. Navigate to results below.'; // announce to screen reader
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment