any one no the html code that centers my website in any browser safri,ff,ie , ex....
any one no the html code that centers my website in any browser safri,ff,ie , ex....
<div align="center">
Peter - alotofstuffhere[dot]com - Email Me - Donate via PayPal - Got spare hardware? Donate 'em to me :) Just send me a PM.
Currently: enjoying the early holidays :)Read before posting: FAQ | What you CAN'T do with JavaScript | Form Rules | Thread Title Naming Guide
The code listed above will centre only the div it styles. This code will centre the entire site. Be sure to "uncentre" those things you want left justified.
HTML Code:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>An XHTML 1.0 Strict standard template</title> <meta http-equiv="content-type" content="text/html;charset=utf-8" /> <meta http-equiv="Content-Style-Type" content="text/css" /> <style type="text/css"> body { margin: 0 auto; /* for modern browsers */ text-align:center; /* for older browsers */ } </style> </head> <body> <div>... site code here <p>... Your HTML content here ...</p> <p> <a href="http://validator.w3.org/">validate the xhtml</a> </p></div> </body> </html>
Last edited by jlhaslip; 02-18-2007 at 06:49 AM. Reason: fix stuff
IE supports XHTML really badly.
http://www.hixie.ch/advocacy/xhtml
Peter - alotofstuffhere[dot]com - Email Me - Donate via PayPal - Got spare hardware? Donate 'em to me :) Just send me a PM.
Currently: enjoying the early holidays :)Read before posting: FAQ | What you CAN'T do with JavaScript | Form Rules | Thread Title Naming Guide
Styling the body like so:
Can lead to more problems in a complex layout than will using a wrapper division:Code:<style type="text/css"> body { margin: 0 auto; /* for modern browsers */ text-align:center; /* for older browsers */ } </style>
Code:<style type="text/css"> #wrapper { margin: 0 auto; /* for modern browsers */ text-align:center; /* for older browsers */ } </style>Also, text-align:center can have unexpected consequences, especially if absolute positioning is used within the content of an element so styled.HTML Code:<body><div id="wrapper"> Your markup here </div></body>
- John________________________
Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate
Is the align attribute depreciated for <p>?
- Mike
Bookmarks