vertical centering of text

G

google

When I view the following in a browser window, the text is not
vertically centered (text is at the top of the window) but in Print
Preview, the text is vertically centered. How can I have the text
be centered in both?

Thanks for your help,
Robert


<HTML>
<HEAD>
<TITLE>My Web Page</TITLE>
</HEAD>

<BODY scroll=yes>

<div align="center">
<table height="75%" border="0" bgimage="../pics/frame_back.jpg">
<tr>
<td>
<font size="6"><p align="center">Text Line
1</p></font><br><br>
<font size="5"><p align="center">Text Line
2</p></font><br><br>
<font size="6"><p align="center">Text Line
3</p></font><br><br>
</tr>
</table>
</div>

</BODY>
</HTML>
 
A

Adrienne Boswell

Gazing into my crystal ball I observed (e-mail address removed) writing in
When I view the following in a browser window, the text is not
vertically centered (text is at the top of the window) but in Print
Preview, the text is vertically centered. How can I have the text
be centered in both?

Thanks for your help,
Robert

You need a Doctype declaration - new pages should use Strict.
<HTML>
<HEAD>
<TITLE>My Web Page</TITLE> </HEAD>

<BODY scroll=yes>

There is no scroll attribute for the Body element.
<div align="center">

Align is deprecated <http://www.w3.org/TR/html4/present/graphics.html#adef-
align>. Use CSS.
<table height="75%" border="0" bgimage="../pics/frame_back.jpg">

There is no attribute height for the table element
<tr>
<td>
<font size="6"><p align="center">Text Line
1</p></font><br><br>

Font element is deprecated. See above for align attribute. What is the
purpose of placing two br elements after a p element. Change the margin
for the p element through CSS.
<font size="5"><p align="center">Text Line
2</p></font><br><br>

<snip rest>

You will do better using CSS. Try Googling for vertical center css.
 
A

Alan Cole

When I view the following in a browser window, the text is not
vertically centered (text is at the top of the window) but in Print
Preview, the text is vertically centered. How can I have the text
be centered in both?

Thanks for your help,
Robert


<HTML>
<HEAD>
<TITLE>My Web Page</TITLE>
</HEAD>

<BODY scroll=yes>

<div align="center">
<table height="75%" border="0" bgimage="../pics/frame_back.jpg">
<tr>
<td>
<font size="6"><p align="center">Text Line
1</p></font><br><br>
<font size="5"><p align="center">Text Line
2</p></font><br><br>
<font size="6"><p align="center">Text Line
3</p></font><br><br>
</tr>
</table>
</div>

</BODY>
</HTML>

VERY old fashioned HTML with lots of errors, but you are missing a </td>
tag which may sort things out in the browser. Although it is centred in
my browser.

Al.
 
G

google

Here is a version using ccs. Vertical centering is better, but still
not quite what I want.

One question I have is why the vertical positioning is different in
Print Preview in ie6 than in the browser window. The text is much
higher on the page when printed out than it appears in the browser
window.

In response to someone else's question about my original html,
I am using <br> to vertically position the lines of text relative to
each other. I put the font size and style in the body rather than
in the css because I want different styles and sizes of text on
different lines. If there is a better way to do that, perhaps in the
css, please let me know how it is best done.

Also, my background image is cut off at the bottom in the browser
window, but looks fine when printed out. There are also no scroll
bars. I realize you don't see my image in the html below, but in
general, why doesn't the browser take into consideration the vertical
size of the background image and either adjust the size of the window
or add scroll bars accordingly?

Again, thanks for the help,

Robert

<HTML>
<HEAD>
<TITLE>My Web Page</TITLE>
<style type="text/css">
<!--
body {
background-color: #FFFFFF;
margin-top: 27%;
font-size: 100%;
background-image: url(../pics/frame_back.jpg);
background-repeat: no-repeat;
background-position: top center;
padding: 0px;
}
-->
</style>
</HEAD>

<body>
<p style="text-align: center; font-family: 'times'; font-style:
'italic'; font-size: 120%">
first line of text<br><br><br><br></p>
<p style="text-align: center; font-family: 'times'; font-style:
'italic'; font-size: 85%">
second line of text<br><br><br><br></p>
<p style="text-align: center; font-family: 'times'; font-size:
120%">
third line of text</p>
</body>
</HTML>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top