Accessibility / Spacing / Text Spacing Bookmarklet

The Text Spacing bookmarklet toggles enhanced text spacing to test WCAG 1.4.12 Text Spacing requirements. Sets line-height to 1.5, letter-spacing to 0.12em, word-spacing to 0.16em, and paragraph margin-bottom to 2em. Applies to main document, shadow DOMs, and iframes. Run again to remove.

WCAG SC 1.4.12: Text Spacing
Run Text Spacing Bookmarklet

Test run or drag to
bookmarklets bar to install

javascript:%21function()%7Bfunction%20t(e)%7Bfor(var%20o%20of%20e.querySelectorAll(%22*%22))if(o.shadowRoot)%7Bvar%20r%3Do.shadowRoot.getElementById(n)%3Br%26%26r.remove()%2Ct(o.shadowRoot)%7D%7Dfunction%20e(t%2Co)%7Bfor(var%20n%20of%20t.querySelectorAll(%22*%22))n.shadowRoot%26%26(n.shadowRoot.appendChild(o.cloneNode(%210))%2Ce(n.shadowRoot%2Co))%7Dvar%20o%3Ddocument%2Cn%3D%22phltsbkmklt%22%2Cr%3Do.getElementById(n)%2Cl%3Do.querySelectorAll(%22iframe%22)%2Ca%3D0%2Cd%3Dl.length%3Bif(r)%7Bif(r.remove()%2Ct(o)%2Cd)for(a%3D0%3Ba%3Cd%3Ba%2B%2B)try%7Bvar%20i%3D(m%3Dl%5Ba%5D.contentWindow.document).getElementById(n)%3Bi%26%26i.remove()%2Ct(m)%7Dcatch(t)%7Bconsole.log(%22Error%20removing%20styles%20from%20iframe%3A%22%2Ct)%7D%7Delse%7Bvar%20c%3Do.createElement(%22style%22)%3Bif(c.id%3Dn%2Cc.appendChild(o.createTextNode(%22%5Cn%5Ct%5Ct%5Ct*%20%7B%5Cn%5Ct%5Ct%5Ct%5Ctline-height%3A%201.5%20%21important%3B%5Cn%5Ct%5Ct%5Ct%5Ctletter-spacing%3A%200.12em%20%21important%3B%5Cn%5Ct%5Ct%5Ct%5Ctword-spacing%3A%200.16em%20%21important%3B%5Cn%5Ct%5Ct%5Ct%7D%5Cn%5Ct%5Ct%5Ctp%20%7B%5Cn%5Ct%5Ct%5Ct%5Ctmargin-bottom%3A%202em%20%21important%3B%5Cn%5Ct%5Ct%5Ct%7D%5Cn%5Ct%5Ct%22))%2Co.head.appendChild(c)%2Ce(o%2Cc)%2Cd)for(a%3D0%3Ba%3Cd%3Ba%2B%2B)try%7Bvar%20m%3B(m%3Dl%5Ba%5D.contentWindow.document).head.appendChild(c.cloneNode(%210))%2Ce(m%2Cc)%7Dcatch(t)%7Bconsole.log(%22Error%20applying%20styles%20to%20iframe%3A%22%2Ct)%7D%7D%7D()%2Cconsole.log(%22%5CnSource%3A%20https%3A%2F%2Fcodepen.io%2Fstevef%2Ffull%2FYLMqbo%5CnBookmarklet%20name%3A%20Text%20Spacing%20(WCAG%20SC%201.4.12)%5Cn%22)%3B
← Back to all bookmarklets