Hi,
How exactly do i use this CSS property?
I know Vinnie has explained this already (and it won't help with you particular problem) but I thought it was worth an example for those who are still not sure what vertical_align does[img]images/smilies/wink.gif[/img].
As mentioned by Vinnie vertical-align determines the alignment of text within a single line of text or within a table cell.
(In a table cell the middle of the element will align with the middle of the cell.)
When used in a line of text vertical-align will position the text with respect to other text on the same line.
This inline layout model is quite complicated but this is the basics of it: For each piece of text an inline box is generated, using the content area (box defined by font-size for each piece of text) and the half leading ((font size -line height)/2) to arrive at it's final height. These boxes will always be centred vertically with respect to each other within the line unless another value is applied to vertical-align.
Perhaps an example would be easier to explain it:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Inline layout model</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<style type="text/css">
<!--
.test {
font-family: Arial, Helvetica, sans-serif;
font-size: 20px;
}
.test span {
font-size:12px;
vertical-align:bottom
}
.test em {
font-size:8px;
vertical-align:top
}
-->
</style>
</head>
<body>
<div class="test">
<p>Hello this is normal text <span>This text is lower down</span><em> and this text is higher up</em></p>
</div>
</body>
</html>
Some browers may not support all the values of vertical-align so testing is necessary.
(Hope this is useful to someone.)
Paul
Bookmarks