Question Locked

Center the Layout

0 helpful
2 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Hi,

I appologise for this lengthy question, I am a beginner in web designing,I use layer drawing for all my page content ( text, flash navigation bar, footer, etc )

I dont know where exactly I place the CSS codes in the sheet so I center all my page content.

my code page is like this below example, can anone tell me which code and where do I place them to center all the page.
P.S : I found those 2 codes,
1) #wrapper {position: relative; width: 760px; margin: 0 auto; text-align: left; }
2)body {text-align: center; }

Here is my code page for one of my pages:

Centering a div or any other block-level element horizontally is a special case for CSS layout, even moreso because there is a bug in Internet Explorer’s implementation of the standard way of doing it. The standard way is to set the element’s horizontal margin values to auto, like so:

#wrapper {width: 760px; margin: 0 auto; }

That will work in browsers like Firefox, Safari or Opera. However, this will have no effect in versions of Internet Explorer below 7. There is a hack we can use though, so that we get horizontal centering in all browsers. To whit, IE incorrectly centers block-level elements if the element that they’re contained in has text-align: center applied. So we can apply this property to the body element, and all the elements within it will be centered.

body {text-align: center; }

One final step is then necessary. The line above will, of course, center all the text inside the centered elements as well, which is generally not what we want, so we need to align the text within back to the left. So here’s all the code:

body {text-align: center; }

#wrapper {width: 760px; margin: 0 auto; text-align: left; }

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

2 replies

by thumbsup2

All of the CSS (everything between the opening and closing STYLE tags) goes between the opening and closing HEAD tags.

All of the OBJECT stuff belongs after the opening BODY tag.

NOTE: If you're a beginner at HTML, you should practice with the simple stuff and learn how and where to properly place various parts of the page before tackling the hard stuff. What you're doing is the equivalent of jumping into the ocean before you've learned to swim and practiced in a swimming pool.

---

This discussion is closed to new replies.