BalconyShore Posted May 29, 2006 Share Posted May 29, 2006 I've started learning html a month ago, so I'm pretty new with techie jargon. Anyway, I've just started learning about CSS, and came across a section in the CSS - Classification page. There's a section on creating a web page without any tables. I tried looking up on how to center the "no table" (is it called a container?). I haven't been able to find what I was looking for. Can somebody help me? Link to comment Share on other sites More sharing options...
asylum Posted May 29, 2006 Share Posted May 29, 2006 The div tags that make up the layout are generally referred to as layers or by their id which is usually something like 'container' or 'content'. The following code will center the whole page where 'someid' is the id of the outermost div. #someid { position: relative; margin: 0 auto;} Link to comment Share on other sites More sharing options...
BalconyShore Posted May 30, 2006 Author Share Posted May 30, 2006 Thank you for clearing up some of my confusion. Layers seems to make more sense to me . Though I did try to incorporate the code with some testing code, and I still wasn't able to get it to center. Could you please tell me what I did wrong? <html><head><style type="text/css">#someid { position: relative; margin: 0 auto;}#top { background-color: #ccc; padding: .5em; position:relative; margin:0; width:90%} .intro { color: red; font-weight: bold; }</style></head><body><div id="someid"><p>Center<p></div><div id="top"> <h1>Chocolate curry</h1> <p class="intro">This is my recipe for making curry purely with chocolate</p> <p class="intro">Mmm mm mmmmm</p> </div></body></html> Link to comment Share on other sites More sharing options...
scott100 Posted May 30, 2006 Share Posted May 30, 2006 Try this: #someid {text-align:center;} Link to comment Share on other sites More sharing options...
BalconyShore Posted May 30, 2006 Author Share Posted May 30, 2006 What I'm trying to do looks like this: http://www.createblog.com/layouts/preview.php?id=5438. I want all of the content in the center and to put a box around it. I've read that tables are slower than using CSS layers, so I'd really would like to do this without using tables. Link to comment Share on other sites More sharing options...
aspnetguy Posted May 30, 2006 Share Posted May 30, 2006 I find that margin: auto will not work unless I have a XHTML DOCTYPE. Try including one...it should center. Link to comment Share on other sites More sharing options...
BalconyShore Posted May 30, 2006 Author Share Posted May 30, 2006 Thanks everyone for the help. I tried text-aligning and it worked for centering everything. Thank you all so much . Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now