Accessibility / Analysis / Accessible Name Consistency
The Accessible Name Consistency bookmarklet compares computed accessible names to visible label text to detect potential WCAG 2.5.3 Label in Name violations. Calculates accessible names using accessibility tree computation, finds nearby visible labels (label[for], parent label, or sibling label), measures text similarity using Levenshtein distance, outlines elements with low similarity (<60%) in red, and displays an alert with the count of problematic items. Hover over outlined elements to see name vs label text and similarity score. Run again to remove.
WCAG SC 2.5.3: Label in Name
Run Accessible Name Consistency
Test run or drag to
bookmarklets bar to install
javascript:%21function()%7B%22use%20strict%22%3Btry%7Bfunction%20e(e)%7Bconst%20t%3De%3D%3Ee%26%26document.getElementById(e)%3F.innerText.trim()%3Bif(e.getAttribute(%22aria-label%22))return%20e.getAttribute(%22aria-label%22).trim()%3Bconst%20n%3De.getAttribute(%22aria-labelledby%22)%3Bif(n)return%20n.split(%2F%5Cs%2B%2F).map(t).filter(Boolean).join(%22%20%22).trim()%3Bif(e.alt)return%20e.alt.trim()%3Bif(e.placeholder)return%20e.placeholder.trim()%3Breturn(e.innerText%7C%7C%22%22).trim().slice(0%2C80)%7Dfunction%20t(e%2Ct)%7Bconst%20n%3De.length%2Cr%3Dt.length%2Co%3DArray.from(%7Blength%3An%2B1%7D%2C()%3D%3EArray(r%2B1).fill(0))%3Bfor(let%20e%3D0%3Be%3C%3Dn%3Be%2B%2B)o%5Be%5D%5B0%5D%3De%3Bfor(let%20e%3D0%3Be%3C%3Dr%3Be%2B%2B)o%5B0%5D%5Be%5D%3De%3Bfor(let%20l%3D1%3Bl%3C%3Dn%3Bl%2B%2B)for(let%20n%3D1%3Bn%3C%3Dr%3Bn%2B%2B)%7Bconst%20r%3De%5Bl-1%5D%3D%3D%3Dt%5Bn-1%5D%3F0%3A1%3Bo%5Bl%5D%5Bn%5D%3DMath.min(o%5Bl-1%5D%5Bn%5D%2B1%2Co%5Bl%5D%5Bn-1%5D%2B1%2Co%5Bl-1%5D%5Bn-1%5D%2Br)%7Dreturn%20o%5Bn%5D%5Br%5D%7Dconst%20n%3D%22a11y-name-oracle%22%2Cr%3Ddocument.getElementById(n)%3Br%26%26r.remove()%3Bconst%20o%3Ddocument.createElement(%22div%22)%3Bo.id%3Dn%2Co.style%3D%22position%3Afixed%3Binset%3A0%3Bpointer-events%3Anone%3Bz-index%3A2147483647%22%3Bconst%20l%3D%5B...document.querySelectorAll(%27a%5Bhref%5D%2Cbutton%2Cinput%2Cselect%2Ctextarea%2C%5Brole%5D%2C%5Btabindex%5D%3Anot(%5Btabindex%3D%22-1%22%5D)%27)%5D.filter(e%3D%3Ee.offsetParent)%3Blet%20i%3D0%3Bfor(const%20a%20of%20l)%7Bconst%20c%3De(a)%7C%7C%22%22%3Blet%20s%3D%22%22%3Bconst%20m%3Da.id%26%26document.querySelector(%60label%5Bfor%3D%22%24%7Ba.id%7D%22%5D%60)%3Bif(m%26%26(s%3Dm.innerText.trim())%2C%21s)%7Bconst%20p%3Da.closest(%22label%22)%3Bp%26%26(s%3Dp.innerText.trim())%7Dif(%21s)%7Bconst%20b%3Da.parentElement%3Bb%26%26(s%3D(b.querySelector(%22label%22)%3F.innerText%7C%7C%22%22).trim())%7Dconst%20d%3Dt(c.toLowerCase()%2Cs.toLowerCase())%2Cu%3D1-d%2F(Math.max(c.length%2Cs.length)%7C%7C1)%2Cf%3Da.getBoundingClientRect()%2Ch%3Ddocument.createElement(%22div%22)%2Cg%3Du%3E%3D.6%7C%7C%21s%26%26c%3Bh.style%3D%60position%3Aabsolute%3Bleft%3A%24%7Bf.left%2BscrollX%7Dpx%3Btop%3A%24%7Bf.top%2BscrollY%7Dpx%3Bborder%3A2px%20solid%20%24%7Bg%3F%22%230a0%22%3A%22%23e00%22%7D%3Bwidth%3A%24%7Bf.width%7Dpx%3Bheight%3A%24%7Bf.height%7Dpx%60%2Ch.title%3D%60name%20%22%24%7Bc%7D%22%20vs%20label%20%22%24%7Bs%7D%22%20score%20%24%7Bu.toFixed(2)%7D%60%2Co.appendChild(h)%2Cg%7C%7Ci%2B%2B%7Ddocument.body.appendChild(o)%2Calert(%60Low%20similarity%20items%3A%20%24%7Bi%7D%60)%2Cconsole.log(%22%5CnSource%3A%20https%3A%2F%2Fgithub.com%2Falejandrogiga98%2FA11y-Bookmarklets%5CnBookmarklet%20name%3A%20Accessible%20name%20consistency%5CnAuthor%3A%20alejandrogiga98%5CnLicense%3A%20MIT%20License%5Cn%22)%7Dcatch(x)%7Balert(%22Bookmarklet%20Error%3A%20%22%2Bx.message)%7D%7D()%3B
← Back to all bookmarklets