I am new to code writing. How do I make it so this page stays centered in web browsers? What HTML code do I add and where?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Direct Selling Rumors & Gossip</title>
</head>
<body bgcolor="066082">
<TABLE align="center" class="" style="BACKGROUND-IMAGE: url(http://www.directsellinglive.com/Rumors/Rumors.jpg)" height="1067" width="1916">
<TBODY>
<TR>


</div></TD></TR></TBODY></TABLE>
</body>
</html>

Recommended Answers

All 8 Replies

It is a problem in Opera browser where align attribute don't work, instead you can use <center> tag which can solve the problem of centering.

<center><TABLE align="center" class="" style="BACKGROUND-IMAGE: url(http://www.directsellinglive.com/Rumors/Rumors.jpg)" height="1067" width="1916"></center>

Thanks! I'll give it a try.

I didn't get what I was looking for. This is the page that I'm trying to center when it opens in a browser. It keeps justifying to the right. I want it to open in the center and stay centered when the page is being closed by being pulling left to right

http://www.directsellinglive.com/Rumors/Rumors.htm

with this code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Direct Selling Rumors & Gossip</title>
</head>
<body bgcolor="066082">
<center><TABLE align="center" class="" style="BACKGROUND-IMAGE: url(http://www.directsellinglive.com/Rumors/Rumors.jpg)" height="1067" width="1916"></center>
<TBODY>
<TR>


</div></TD></TR></TBODY></TABLE>
</body>
</html>

Any thoughts?

Both

<center>

and

align="center"

have been depreciated in the newer html versions.
Go with :

<table style="margin:0 auto; text-align:center;"

It's valid to html5.

Okay - posted then saw the reply. What you have is a background graphic in a table. Add

; background-repeat:no-repeat; background-position:top center

after the background-image in the table style. However, fixing the table height and width will keep the table from shrinking and expanding. Go with percentages with a fixed min-width like:

<table style="margin:0 auto; text-align:center; width:100%; min-width:800px; background-image: url(http://www.directsellinglive.com/Rumors/Rumors.jpg); background-repeat:no-repeat; background-position:top center"

OR take the background graphic out of the table and make it the background of the body.

This is all new to me. Can you tell where in the code do I put...
<table style="margin:0 auto; text-align:center; height:1067px; width:1916px"

What should the new code look like?

Below is my current code.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Direct Selling Rumors & Gossip</title>
</head>
<body bgcolor="066082">
<center><TABLE align="center" class="" style="BACKGROUND-IMAGE: url(http://www.directsellinglive.com/Rumors/Rumors.jpg)" height="1067" width="1916"></center>
<TBODY>
<TR>


</div></TD></TR></TBODY></TABLE>
</body>
</html>


Thanks for your help.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Direct Selling Rumors & Gossip</title>
</head>
<body style="background-color:#066082">
<table style="margin:0 auto; text-align:center; width:100%; min-width:800px; background-image: url(http://www.directsellinglive.com/Rumors/Rumors.jpg); background-repeat:no-repeat; background-position:top center">
<TBODY>
<TR><td>


</TD></TR></TBODY></TABLE>
</body>
</html>

or

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Direct Selling Rumors &mp; Gossip</title>
</head>
<body style="background:#066082 url(http://www.directsellinglive.com/Rumors/Rumors.jpg); background-repeat:no-repeat; background-position:top center;">
<table style="margin:0 auto; text-align:center; width:100%; min-width:800px;">
<TBODY>
<TR><td>


</TD></TR></TBODY></TABLE>
</body>
</html>

One of these should get you close.

You all have been fantastic! I am glad I found this community.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.