I have the following html:
- element 1
- element 2
<
What you're trying to do resembles what table cells do and is impossible otherwise, without using JavaScript (I don't suggest using tables or JavaScript for this, however). Your best bet is to set a certain amount of horizontal padding on the tags and float them so that they are auto-width based on their content's width instead of the window's width:
- element 1
- element 2
The other method is to use display: inline-block; to achieve what you want, but it's kind of a hack (not cross-browser compatible).