
Originally Posted by
Medyman
or adding the following to it's parent div:
Actually from my knowledge, this will not work, looking at it, it says "text" witch to me, seems like it may mean text or images. Not "divs", but will apply to text inside the child divs, for example:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Centered text. Not div</title>
<style type="text/css">
#parentDiv {
width: 70%;
height: 100px;
border: 1px solid #000;
background: #D6FFD8;
padding: 20px;
text-align: center;
}
.inside {
height: 70px;
width: 70px;
border: 1px solid #000;
background: #FFFFF4;
</style>
</head>
<body>
<p>Below, shows a big box, with a little box inside that is not centered, but inside of the little box, has text. And that <b>is</b> centered.</p>
<div id="parentDiv">I'm centered!<div class="inside">Same!</div></div>
</body>
</html>
Will show one box that spreads across the page, and another one that is only 70 * 70px, it has the text-align centered property, but only the text inside the child div, and parent div are centered. Not the parent div itself.
Bookmarks