rod mclaughlin


How HTML5 has improved putting things in the middle of a page (24 jan 13)

It used to take one line. Now, it takes about thirteen:

This is how centering used to be:

<center>This is centered</center>

This is how it is now:
<style>
div.outer {
    display:table;
    width:95%; 
}
div.inner {
    display:table-cell; 
    vertical-align:middle;
    text-align:center;
    width:90%;
}
div.thebox { 
    display:inline-block; 
}
</style>

<div class='outer'> <div class='inner'>
<div class='thebox'>This is centered</div>
</div> </div>

Thanks, Stack Overflow.


 



Back
Portland London