Skip to content

Instantly share code, notes, and snippets.

@robmiller
Created August 20, 2024 16:05
Show Gist options
  • Save robmiller/3b380745d1ad0c2104bc77641ac2bf5c to your computer and use it in GitHub Desktop.
Save robmiller/3b380745d1ad0c2104bc77641ac2bf5c to your computer and use it in GitHub Desktop.
Extremely simple polyfill for hanging-punctuation in Chrome
/*
I only really use hanging-punctuation: first and only expect it to
work in blockquotes, which makes the usage extremely simple. And yet
for some reason I've never done a simple polyfill. Now I have.
*/
(function() {
if ( !CSS.supports("hanging-punctuation", "first") ) {
document.querySelectorAll("p").forEach(e => { if ( e.innerText.trim()[0] == "“" ) { e.style.textIndent = "-0.725ch"; } });
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment