Example: jsfiddle.net/h5sE6/
css:
ul {
float: left;
margin-right:20px;
}
ul li {
height: 3em;
border: 1px solid #ff0000;
width:200px;
}
html:
<ul>
<li> Some text</li>
<li>Some text<br />some more text</li>
<li>some test text3</li>
<li>even more text<br />and more</li>
</ul>
<ul>
<li> Some text</li>
<li>Some text<br />some more text</li>
<li>some test text</li>
<li>even more text<br />and more</li>
</ul>
This is trivial with vertically aligning text and making the height equal to the line-height if you have one line only but any more than that, things look really screwy.
You can do it with a helper
:beforeelement and by adding a nested<span>:Here’s a demo of it in action.
This works because two inline-block elements will vertically align with each other. The
:beforerule creates an inline-block element that is the same height as its parent, which the variable height<span>can vertically align with.For a complete explanation of how it works, see this answer about vertically aligning images.