问题 I'm using an <ol> to show a code snippet with line numbers. Since I'm showing program code, I disable wrapping (and enable indentation) by setting white-space: pre on li , which means an li 's content can extend past the right margin and cause the page to have a horizontal scroll bar. So far so good. The problem comes when I want to set background colors on some of the li s to call out particular lines of code. I can set background-color on the li , but the color only extends to the right