Skip to content
Blog post thumbnail: Code Block Accessibility Improvement: Line Numbers That Screen Reader Users Can Choose - We've improved the accessibility of code blocks in our Hugo blog for screen reader users. (https://www.codeslog.com/en/posts/code-block-accessibility-improvement/)

Code Block Accessibility Improvement: Line Numbers That Screen Reader Users Can Choose

Introduction Recently, I started building and operating a blog using Hugo with the PaperMod theme. Using someone else’s theme has the advantage of quick setup, but not everything fits my needs perfectly. After customizing many parts to match my preferences, I noticed some issues with the code blocks. Line numbers were implemented with <table> tags. While this doesn’t violate accessibility guidelines, it felt not semantic. Moreover, I wondered: what’s the experience for screen reader users? I found a better approach using CSS Counters. ...