June 12, 201016 yr Hi I've read somewhere that the CSS code for centering, <center></center> is deprecated. So what should we be using instead? I understand there is a code for centering text, which I forgot but is something like text-align=center or something. What is it exactly? Also, what about centering things other than text, like images?
June 12, 201016 yr defo text-align:center; if you want to centre a div then margin:0 auto; It's not good practice to just put this is a style on the page. Allways place any ccs code in a stylesheet wherever possible. Take a look at: CSS Basics Regs, Numb
June 14, 201016 yr Bear in mind you also need to specify width if you're going to centre with margin:0 auto;
June 14, 201016 yr Author Thanks notbanksy, but either way (with or without width) I can't get it to work.
June 14, 201016 yr Author I have for example <div style="margin:0 auto width:55%">Hello Notbanksy</div> but this isn't centering.
June 15, 201016 yr Should be <div style="margin:0 auto; width:55%">Hello Notbanksy</div> Note the ; after auto.
June 15, 201016 yr Author Yay, that does it bocaj Also it seems that for it to be centered more exactly, the best is to set width at 0px, at least on my screen.
Create an account or sign in to comment