<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Crystal Groves &#187; Web Development</title>
	<atom:link href="http://crystalgroves.net/category/web-development/feed/" rel="self" type="application/rss+xml" />
	<link>http://crystalgroves.net</link>
	<description>HTML/CSS Developer and Musician in MD and PA</description>
	<lastBuildDate>Tue, 07 Sep 2010 02:40:23 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Center a Page Vertically and Horizontally in HTML</title>
		<link>http://crystalgroves.net/center-a-page-vertically-and-horizontally-in-html/</link>
		<comments>http://crystalgroves.net/center-a-page-vertically-and-horizontally-in-html/#comments</comments>
		<pubDate>Thu, 27 Aug 2009 16:55:27 +0000</pubDate>
		<dc:creator>Crystal</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[tips and tricks]]></category>

		<guid isPermaLink="false">http://crystal.earth-byte.com/?p=521</guid>
		<description><![CDATA[To center a page vertically and horizontally in HTML is fairly simple. The method below works in all Windows browsers and I believe all Apple browsers, but it has trouble working in Linux browsers from what I&#8217;ve seen (I&#8217;ve seen it not work for the vertical alignment, only for horizontal, but this could have changed [...]]]></description>
			<content:encoded><![CDATA[<p>To center a page vertically and horizontally in HTML is fairly simple.  The method below works in all Windows browsers and I believe all Apple browsers, but it has trouble working in Linux browsers from what I&#8217;ve seen (I&#8217;ve seen it not work for the vertical alignment, only for horizontal, but this could have changed since).</p>
<h3>Essentially all you do is:</h3>
<ol>
<li>Position your container div absolutely.</li>
<li>Place the top and left positions as 50%.</li>
<li>Set a height and width (since this is also for centering vertically).</li>
<li>Set the top and left margins to a negative number that is half the height and width you set.  So if your width is 300 pixels, you&#8217;d set your margin-left to -150 pixels.  If your height is 400 pixels, then set your margin-top to -200 pixels.</li>
</ol>
<p><strong>Sample:</strong><br />
<code><br />
.wrapper_container {<br />
	position: absolute;<br />
	top: 50%;<br />
	left: 50%;<br />
	width: 900px;<br />
	height: 545px;<br />
	margin-left: -450px; /*set to a negative number 1/2 of your width*/<br />
	margin-top: -272px; /*set to a negative number 1/2 of your height*/<br />
	background: url("/images/ui/splash.jpg") top left no-repeat;<br />
	display: block;<br />
}<br />
</code></p>
<p>Naturally most people just want to center horizontally, in which case everyone just sets the body tag to text-align center (for IE), and then the container div to margin: 0 auto; (for FF).  This is fairly common practice, I&#8217;m just including it here for posterity.</p>
<p>Sample:<br />
<code><br />
body {<br />
	text-align: center;<br />
}</code></p>
<p><code><br />
.wrapper_container {<br />
	width: 980px;<br />
	margin: 0 auto;<br />
}<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://crystalgroves.net/center-a-page-vertically-and-horizontally-in-html/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
