I may be trying to do something impossible; I am working on a site that displays poetry. I would like poetic lines to both have numbers on the left-hand side; and to wrap properly for poetry (that is, to have sort of hanging indent). I have achieved that using:
- a
pwhich contains both the line-number and the text of the line of poetry; I usetext-indentandpadding-leftapplied to paragraphs of this class to create the sort of indentation I need. - a
spanfor the line number (to style it differently); - a
spanfor the content of the line of poetry itself.
It is works the way I want (you can see an example here), except when the line number transitions from single to double digits, it bumps the indentation of the text of the line of poetry (look at lines 9 and 10 in the linked example).
The most obvious (and, I fear, only) solution is to make my span containing the line number in the an inline-block; but this breaks the desired indentation behavior I want. If I try to apply the padding-left/text-indent onto the text of the line of poetry itself, that means the line-number and line-text are separate blocks, and so they don't stay together when the line wraps (leaving the line number on a line by itself). Is there a way to achieve what I want (line numbers that align properly without breaking the desired indentation behavior) using HTML and CSS? I am open to restructuring things, but would prefer to avoid a whole slew of JS. (As I write this, it occurs to me: could I just insert a non-breaking space after single digits numbers?)
Many thanks.
<li>tag. You'd have the numbering you want automatically and can use css to do more aligning without messing up the numbers.tables. You want horizontal and vertical alignment for the line numbers, otherwise I'd suggest having a single verticaldivdown the left hand side to contain the line numbers.