If I use a monospaced font for the dates, I can give the span some padding-right, use margin-left and text-indent just right and everything seems to always line up pixel-perfect across devices.
However, I’m wondering if this is possible when not using a monospaced font for the dates? As you can see in the image, my usual technique then fails (more or less, depending on the spacing of the dates).
Is there a way I can perfectly line up the text titles (even when breaking) without using a table? Since both are already wrapped anyway, maybe there’s an obvious positioning technique I’m unfamiliar with. Or if I find one, I might spend 2 days and discover gotchas later…
Yes that’s very close to tabular data so semantically a table wouldn’t be that bad (which is effectively what I turned the list into as regards formatting).
The data could probably fit more semantically into a dl element with the date as the data term and the title as the data description but would be awkward to style in the required way.
For user feedback, I sometimes give the title a background color. This now highlights the whole cell, which is not always what I prefer. Is it possible to only go as far as the text in the cell?
You’d have to wrap the text in a span and give a background colour to the span as display:table-cell will always fit the parent’s width. Even if we removed the width from the table the right cells would always be as long as the longest content in that structure.
Thanks. That’s not a huge problem, cos it’s usually from a click and jQuery initiated, so I don’t have to put it on all text beforehand. I’m gonna try that