View Full Version : centering in css


e_curls
02-06-2005, 09:43 AM
if I were to include this code in a stylesheet, would this section of my page be centered???

.content {
position:center;
top:0px;
width:620px;
margin:10px;
background:#fff;
}


i want to dictate how many pixels i want a certain layer but i want it to be centered in the browser ... can anyone help me out? thanks

wergo
02-06-2005, 09:51 AM
you could of course, just put <div align="center" id="content"> that works

e_curls
02-06-2005, 09:58 AM
sweet ... i'll try that out ... thanks

----

edit:

whoops ... tried it out but all it did was center the text that was in that layer ... :o(

MaGiCSuN
02-06-2005, 12:42 PM
position: center;

there's no such thing as that tag you have used there :)
Can we see the page you are working on currently? that would help loads :) since i probably know a solution for this but i can't really explain without seeing how you build up that layout :)

Love,
Mirna

kittycat
02-06-2005, 01:40 PM
.content {
margin: 10px auto;
width:620px;
background:#fff;
}

That's the 'proper' CSS way to centre, although it doesn't work in IE. For it to work there you have to add text-align: center; to the body portion of your stylesheet.

Also instead of the code wergo posted you would use this for your div:
<div class="content">
.name is for classes
#name is for ids.