Forum Moderators: open
I will have frequently changing paragraphs of text plus other variables so setting top and bottom margin each time is not a great improvement on mandraulic positioning.
Setting top and bottom margins to auto did not work either.
If I can get this sorted, updating page content will be much quicker and also any browser text re-sizing will be taken care of.
What's just as important is "No Tables"
this will adjust the height according to how many lines of text you have
it works by wrapping the text in a seperate div...
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title></title>
<style type="text/css"><!--
.div{
position: absolute;
top: 40px;
left: 100px;
width: 300px;
text-align: center;
border-width: 1px;
border-style: solid;
border-color: #009;
padding-top: 50px;
padding-bottom: 50px;
}
--></style>
</head>
<body>
<div class="div">
<div>
<p>sample text here</p>
<p>more text here</p>
<p>more text here</p>
<p>last line here</p>
</div>
</div>
</body>
</html>
:)
Suzy
What vertical-align does is align the element with the style applied to it relative to other inline elements contained in the same line box [w3.org]. Applying vertical-align to a div has no effect on the contents of the div.
To further confuse matters, vertical-align has a different meaning in the case of table cells [w3.org]. Since this definition conforms more to what one expects out of vertical-align, it leads to an interesting hack (which, alas, only works in Mozilla):
div#yourDivId {
display: table-cell;
} Will center the content of the element <div id="youDivId"></div> like you expect in Mozilla.
I have found inline formatting to be a confusing subject, and others have as well. Eric Meyer wrote a short essay [meyerweb.com] on the subject of inline formatting, which might help understanding a bit. AFAIK, there is no easy CSS way of vertically-aligning the content of a block element.