Inquisitiones Mathematicae

Math, Programming, and Opinions

Line Numbering with CSS

A Blog Entry

Posted: 22 December 2016

Time to Read: 3 mins

comments

I was asked about adding linenumbers to code blocks with only css properties in a github issue. Here is a fully contained, pretty simple example.

The line numbers are added by css, and (on most browsers) they are not selectable. So it is still easy to copy the correct code.

The relevant css file is also separated out.

def Hello_World():
    print("Hello World")
    return

def Goodbye_World():
    print("Goodbye World")
    return