I am trying to create a list of definitions so that each dt floats to the left of the corresponding dd elements. I used:
dt { clear: both; float: left; width: 6em; } dd { margin-left: 6.5em; }
which works as much as possible. It perfectly handles several dd elements for dt and dd text, which is long enough to span multiple lines.
However, I would really like to deal with a few dt elements on dd (which are valid HTML) and dt elements that are higher than the corresponding dd elements (due to the length of the text causing the line wrapping). At this point, the style falls apart, and subsequent dd elements go beyond the line with their dt .
I tried different things like float dd , which breaks the alignment of multiple dd elements. Add dd + dd { clear: both; } dd + dd { clear: both; } , which almost works, but now the long text dd is under its dt (not to mention the old browsers that do not follow the rule).
Has anyone been able to do this? I really do not want to give up and use the table, but perhaps this is appropriate.
My test markup is here: http://pastebin.com/nmAQ5Xdm
html css
Rob fletcher
source share