Forum Moderators: not2easy

Message Too Old, No Replies

align center problem

         

priteshgupta

10:18 pm on May 31, 2009 (gmt 0)

10+ Year Member



hi..
I have created a site. I want to put all the content in the center of the screen.
so I have written the code:
<body>
<table align="center">
<tr>
<td align="center">
Here goes all the content + menu+ logo+ banner
</td>
</tr>
</table>
</body>

It is working fine for some pages like home ,aboutus
but for every other page content is not in the center.
please help me on this.
Sorry i can't paste the code for each page so i am giving the link of website <snip>

[edited by: swa66 at 10:45 pm (utc) on May 31, 2009]
[edit reason] No personal URLs allowed, please see ToS and forum charter [/edit]

swa66

10:53 pm on May 31, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



align="center" isn't CSS, it's html doing layout and is at least in some versions of html depreciated at best.

The way to do centering with CSS is depend on the element:
- a block can be centered by giving it width and auto margins at the left and the right
- an absolute positioned block can be centered by using a combination of rist setting one side to the middle (e.g. left: 50%) and then moving the margin back with half the width of the element itself (e.g. margin-left: -100px; /* supposing it's 200px wide */)
- to center inline content, there's text-align: center;
- ...