Center div with css and html
This is very common and suprisingly hard to do:
As I currently understand it:
If an element has an auto margin, it is centred when the element has a width. Should the element be positioned absolutely, it is only centred if the attributes left and right are specified (top and bottom for vertical alignment). The following should centre the element both vertically and horizontally:
#box {background-color: orange;
position: absolute;margin:auto;
width:100px; height:100px;
left:0px; right:0px;
top:0px; bottom:0px;
}
Hope this helps.