Hi all, I'm creating my first website. I want to put a box to middle of the screen. I thought I just need to get the screen-width to get the margin on one side of the box to place it into the middle: <script type="text/javascript"> var embreite = screen.width/16; /* 1em is 16 pixel, isn't it ?? */ var boxbreite = 70; /* width of the box */ var rand = embreite-boxbreite; var randleft = rand/2; </script> But when I take "randleft" as the margin-left of the box, it is still not in the center, just a little bit more right. What am I doing wrong?
Or maybe not ... <center> Deprecated. have a look at: http://www.tutorialspoint.com/html/html_tags_ref.htm
If it's deprecated then browser makers *could* drop support for the element in future. I doubt <center> will validate as well-formed HTML if it's deprecated, don't know if you are concerned about that sort of thing? Another way to center a box horizontally is to use CSS: <div style="width:300px;margin-left:auto;margin-right:auto;">your stuff</div>