ul.tags { list-style-type: none; } ul.tags li { padding-left: .5em; padding-right: .5em; display: inline-block; } pre.showlines { white-space: pre-wrap; } pre.showlines::before { counter-reset: listing; } pre.showlines code { counter-increment: listing; } pre.showlines code::before { content: counter(listing) ". "; display: inline-block; width: 3em; /* now works */ text-align: right; /* now works */ }