Jump to content

How to align web page in centre


tckoon
 Share

Recommended Posts

Can you show the code of your site?Depending on how your code it you'll need a different method to center it.
Here the sample page format codes.<!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><meta http-equiv="Content-Language" content="en-us" /><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>TEST 123</title><style type="text/css">.style1 { font-size: xx-large;}</style></head><body style="margin-left: 5px; margin-right: 5px"><div style="position: absolute; width: 555px; height: 486px; z-index: 1; left: 5px; top: 15px" id="layer1"> <div style="position: absolute; width: 530px; height: 100px; z-index: 1; left: 9px; top: 7px" id="layer2"> <div style="position: absolute; width: 100px; height: 370px; z-index: 1; left: 3px; top: 106px" id="layer3"> <div style="position: absolute; width: 419px; height: 353px; z-index: 1; left: 111px; top: 5px" id="layer4"> <iframe name="I1" id="I1" style="width: 394px; height: 342px" src="products/main%20products.htm" border="0" frameborder="0">Your browser does not support inline frames or is currently configured not to display inline frames. </iframe></div> HOME<br /> <br /> PRODUCTS<br /> <br /> CONTACT</div> <strong><span class="style1">abc.com<br /> <br /> </span><hr /></strong></div></div></body></html>
Link to comment
Share on other sites

Ouch, that code doesn't look very good, you should be using an XHTML Frameset Doctype for frames, not Transitional.Anyways, to center your iframe, just add this:<iframe name="I1" id="I1" style="width: 394px; height: 342px; margin: 0 auto" src="products/main%20products.htm" border="0" frameborder="0">

Link to comment
Share on other sites

The Transitional DTD is what is required in order to allow the use of iframes.http://www.w3.org/TR/html4/index/elements.htmlBut the use of postion:absolute might be an issue for the centering of the page.Essentially, the margin: 0 auto; should do it for you, subject to the absolute positioning. Absolute positioning should be avoided. Margins, Padding and Floats handle positioning much easier, and usually cross browser.

Link to comment
Share on other sites

You'll have to change a lot of your code, you've used absolute positioning for your elements.I'll fix up your page for you:

<!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>	<meta http-equiv="Content-Language" content="en-us" />	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />	<title>TEST 123</title>	<style type="text/css">	html,body {	margin: 0;	padding: 0;	text-align: center;	}	#wrapper {	width: 555px;	margin: 0 auto;	text-align: left;	}	#menu {	 width: 100px;	 float: left;	}	#menu ul {	padding: 0;	margin: 0;	list-style-type: none;	}	#content {	margin-left: 100px;	}	#content iframe {	width: 100%;	height: 342px;	}	</style>  </head>  <body style="margin-left: 5px; margin-right: 5px">	<div id="wrapper">	  <div id="header"><h1>abc.com</h1><hr /></div>	  <div id="menu">		<ul>		  <li>HOME</li>		  <li>PRODUCTS</li>		  <li>CONTACT</li>		</ul>	  </div>	  <div id="content">		<iframe id="I1" src="products/main%20products.htm" frameborder="0">		  Your browser does not support inline frames or is currently configured not to display inline frames.		</iframe>	  </div>	</div>  </body></html>

Link to comment
Share on other sites

Why in the world is a Frameset DTD being used there?
I was still writing the message while you posted yours.I didn't look strictly through the specification, I just was under the impression that a frame would be proper under the frameset DTD. I didn't check to see if it was available in Transitional.I've never had to use frames of any kind before
Link to comment
Share on other sites

Guest FirefoxRocks
I was still writing the message while you posted yours.I didn't look strictly through the specification, I just was under the impression that a frame would be proper under the frameset DTD. I didn't check to see if it was available in Transitional.I've never had to use frames of any kind before
I don't see any frames in the document though. There's no <frame>, <frameset> or <noframes> there. :)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...