...

View Full Version : Centering a div tag



dougancil
12-17-2010, 03:51 PM
I am building a web page and have 3 div tags that I'm trying to center. The web page is a conversion from psd to html and I used Photoshop to convert the file to html. I am also using CSS for a few of the elements on the page. The problem I'm having is that the 3 div tags are showing aligned left and aren't auto aligning when people open the page. Here is the html for the section as it stands now:



<DIV STYLE="position:absolute; top:143px; margin-left:auto;margin-right:auto; width:533px; height:98px; font: Franklin 'Franklin Gothic Demi Cond';"">
<FONT SIZE="4" COLOR="#FFFFFF">This is an editable area</FONT>
</DIV>


I've tried several versions of this code and can't seem to get the box centered. Can anyone assist with this?

Thank you

Doug

teedoff
12-17-2010, 03:56 PM
Please post a link to the page in question.

Rowsdower!
12-17-2010, 04:40 PM
Yep, we need to see your whole page for best results. BUT, before that, you will need to run your HTML through the HTML validator (http://validator.w3.org/) and clean up all of the errors and warnings associated with your HTML code. CSS is not fully reliable when applied to invalid HTML and if you wrestle the CSS into submission first and then validate the HTML later you end up having to do the CSS all over again anyway.

So... the first step is to validate the HTML that photoshop created for you, and the second step is post a link to your page.

ajetrumpet
12-18-2010, 08:52 AM
wouldn't an attribute align be fine?


<DIV align="center" STYLE="position:absolute; top:143px; margin-left:auto;margin-right:auto; width:533px; height:98px; font: Franklin 'Franklin Gothic Demi Cond';"">
<FONT SIZE="4" COLOR="#FFFFFF">This is an editable area</FONT>
</DIV>

just a thought. maybe the wrong one. isn't that available?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum