Compare all vertical-align settings in HTML and CSS

Description

The following code shows how to compare vertical-align:baseline;sub;super;top;text-top;middle;bottom;text-bottom;.

Example


<html>
<head>
<style type='text/css'>
div {border-style:solid; border-width:1px; border-color:#000000; width:200px; margin-bottom:10px;}
<!--   w  ww.j  a v  a2s .c o m-->
.plain {color:#FF0000;}
.baseline {vertical-align:baseline;}
.sub {vertical-align:sub;}
.super {vertical-align:super;}
.top {vertical-align:top;}
.texttop {vertical-align:text-top;}
.middle {vertical-align:middle;}
.bottom {vertical-align:bottom;}
.textbottom {vertical-align:text-bottom;}
.oneHundredPercent {vertical-align:100%;}
.fiftyPercent {vertical-align:50%;}
</style>

</head>

<body>
<h1>vertical-align</h1>

<div>
<span class="plain">Plain text</span> <span>no vertical align</span><img class="baseline" src="images/block.gif" width="50" height="50" alt="block" />
</div>
<div>
<span class="plain">Plain text</span> <span class="baseline">baseline</span><img class="baseline" src="images/block.gif" width="50" height="50" alt="block" />
</div>
<div>
<span class="plain">Plain text</span> <span class="sub">sub</span><img class="sub" src="images/block.gif" width="50" height="50" alt="block" />
</div>
<div>
<span class="plain">Plain text</span> <span class="super">super</span><img class="super" src="images/block.gif" width="50" height="50" alt="block" />
</div>
<div>
<span class="plain">Plain text</span> <span class="top">top</span><img class="top" src="images/block.gif" width="50" height="50" alt="block" />
</div>
<div>
<span class="plain">Plain text</span> <span class="texttop">texttop</span><img class="texttop" src="images/block.gif" width="50" height="50" alt="block" />
</div>
<div>
<span class="plain">Plain text</span> <span class="middle">middle</span><img class="middle" src="images/block.gif" width="50" height="50" alt="block" />
</div>
<div>
<span class="plain">Plain text</span> <span class="bottom">bottom</span><img class="bottom" src="images/block.gif" width="50" height="50" alt="block" />
</div>
<div>
<span class="plain">Plain text</span> <span class="textbottom">textbottom</span><img class="textbottom" src="images/block.gif" width="50" height="50" alt="block" />
</div>
<div>
<span class="plain">Plain text</span> <span class="oneHundredPercent">100%</span><img class="100percent" src="images/block.gif" width="50" height="50" alt="block" />
</div>
<div>
<span class="plain">Plain text</span> <span class="fiftyPercent">50%</span><img class="50percent" src="images/block.gif" width="50" height="50" alt="block" />
</div>

</table>
</body>
</html>

Click to view the demo

The code above generates the following result.

Compare all vertical-align settings in HTML and CSS
Home »
  HTML CSS Tutorial »
    Text »
      CSS Text Style
...
Set paragraph line-height to 150% in HTML a...
Compare text-align all possible values in H...
Set text-align to center in HTML and CSS
Set text-align to justify in HTML and CSS
Set text align to justify to paragraph in H...
Set text-align to left in HTML and CSS
Set text-align to right in HTML and CSS
Compare text-decoration in HTML and CSS
Set text-decoration to line-through in HTML...
Set text-decoration to none for visited anc...
Set text-decoration to overline in HTML and...
Set text-decoration to underline in HTML an...
Set text-decoration to underline overline i...
Set text-decoration to underline overline l...
Compare text-transform in HTML and CSS
Set text-transform to capitalize in HTML an...
Set text-transform to lowercase in HTML and...
Set text-transform to uppercase in HTML and...
Compare all vertical-align settings in HTML...
Compare vertical-align possible values in H...
Compare vertical align values in HTML and C...
Set vertical align for table cells in HTML ...
Set vertical-align to 300% in HTML and CSS
Set vertical-align to 69px in HTML and CSS
Set vertical-align to baseline in HTML and ...
Set vertical align to bottom in HTML and CS...
Set vertical-align to middle in HTML and CS...
Set vertical-align to sub in HTML and CSS
Set vertical-align to super in HTML and CSS
Set vertical-align to text-bottom in HTML a...
Set vertical-align to text-top in HTML and ...
Set vertical-align to top in HTML and CSS
Set white-space to normal in HTML and CSS
Set white-space to nowrap in HTML and CSS
Set white-space to pre in HTML and CSS
Set word-spacing to 10px in HTML and CSS
Set word-spacing to 3em; in HTML and CSS
Set word-spacing to -5px in HTML and CSS
...