I’m designing a contact page and would like to have 2 columns, one with a label (e.g. facebook, twitter) and one with the actual details. The thing is I want the two lines (which have text of different size) to both align along the bottom edge.
It’s probably easier if I show you: http://goonbee.com/contact
At the moment, the label and details are vertically aligned along the centre. How can I make them align along the bottom?
My CSS is:
#contactbox {
display: block;
margin-top: 25px;
}
#contactboxlabels {
font-family: Arial, Helvetica, sans-serif;
font-size: 17px;
color: #c9c9c9;
line-height: 42px;
text-align: right;
float: left;
padding: 0;
margin: 0;
}
#contactboxdetails {
font-family: Arial, Helvetica, sans-serif;
font-size: 35px;
color: #545454;
line-height: 42px;
text-align: left;
vertical-align: bottom;
float: left;
padding: 0;
margin: 0;
margin-left: 15px;
}
My HTML:
<div id="contactbox">
<div id="contactboxlabels">
<span>email<br />twitter<br />facebook<br />phone</span>
</div>
<div id="contactboxdetails">
<span><a href="mailto:x@x.com">x@x.com</a><br /><a href="http://twitter.com/goonbee">@goonbee</a><br /><a href="http://facebook.com/goonbee">facebook.com/goonbee</a><br /><a href="tel:+44000000">+44 000000</a></span>
</div>
<div style="clear:both"></div>
</div>
First, your markup is not very semantic. The keys belong with their values, they are not an independent column. This would be the most semantic, minimal markup:
For styling this, the only drawback is that you need to set the width of your
dt“column” explicitly in order to get them to line up:You can then adjust
line-heighton thedtand addpadding-topto keep the heights the same and match up the baselines:Alternatively, if you don’t want to set the width of the left column and have it align based on the longest element, like a table column, then use a table! This would give you better control over the
vertical-alignas well. I don’t think a table would be inappropriate here, especially if you mark up the left column asthheaders.