Skip to content

Instantly share code, notes, and snippets.

/**
* Gets keyboard-focusable elements within a specified element
* @param {HTMLElement} [element=document] element
* @returns {Array}
*/
function getKeyboardFocusableElements (element = document) {
return [...element.querySelectorAll(
'a, button, input, textarea, select, details,[tabindex]:not([tabindex="-1"])'
)]
.filter(el => !el.hasAttribute('disabled'))
Seven different types of CSS attribute selectors
// This attribute exists on the element
[value]
// This attribute has a specific value of cool
[value='cool']
// This attribute value contains the word cool somewhere in it
[value*='cool']
<article>
<header>
<h1>Article title</h1>
<time datetime="2019-12-03">December 3, 2019</time>
</header>
<section aria-label="quick summary">
<p>...</p>
</section>
<nav aria-label="breadcrumbs">
<ol>
<li>
<a href="/">Home</a>
</li>
<li>
<a href="/parent">Parent</a>
</li>
<li>
<a href="/parent/current" aria-current="location">Current</a>
/*
1 - Hat tip Nick/cssremedy (https://css-tricks.com/revisiting-prefers-reduced-motion-the-reduced-motion-media-query/#comment-1700170)
*/
@media screen and
(prefers-reduced-motion: reduce),
(update: slow) {
* {
animation-duration: 0.001ms !important;
animation-iteration-count: 1 !important; /* 1 */
transition-duration: 0.001ms !important;
:root {
--x: 1;
--a: 1;
--b: 1;
/* not(x) */
--notx: calc(1 - var(--x));
/* a and b */
@ejur4s
ejur4s / tokens.css
Last active February 11, 2020 20:28
:root {
--font-family-sans-serif:
-system-ui,
-apple-system,
BlinkMacSystemFont,
"Segoe UI",
Roboto,
Oxygen,
Ubuntu,
Cantarell,
@ejur4s
ejur4s / template.html
Last active December 28, 2019 17:54
Accessible HTML template (source: https://majder.com/semantic-markup/)
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="This is a website of a non existing company.">
<link rel="shortcut icon" href="./favicon.ico">
<title>Company name</title>
<script src="https://unpkg.com/[email protected]/package.js"></script>
</head>

Keybase proof

I hereby claim:

  • I am ejur4s on github.
  • I am ejur4s (https://keybase.io/ejur4s) on keybase.
  • I have a public key ASBt44001Q1DtlBrxCpjeffJai15pS9JsSC5HPyug6b4RQo

To claim this, I am signing this object: