Click to See Complete Forum and Search --> : center


toshog
05-28-2007, 06:56 AM
hi all...
can somebody please explain why this doesn;t do what it should:
http://guey.el.net/k/tests/center.html

css is inline...

very, very basic - i need the the main div centered and then the content one in it with text there aligned to the left.
i'm looking at firefox and safari right now....

thanks...

Fang
05-28-2007, 08:27 AM
Why the float?<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<title>Basic center page with elements position:absolute</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
html, body {
margin:0;
text-align:center;
}
#container {
margin:0 auto;
width:80%; /* change to required width */
text-align:left;
}
#contents { /* any element here is centered */
border:1px solid red;
}
</style>
</head>
<body>
<div id="container">
<div id="contents">
<p>contents</p>
</div>
</div>
</body>
</html>

toshog
05-29-2007, 10:18 PM
Why the float?
why not?
isn;t that what makes a <div> aligned left/right?! how's text-align better?

margin:0 auto;
this was all i had to add to my main class... i guess the 'auto' makes the differnce... thank you....