Please look at the markup... <html xmlns="http://www.w3.org/1999/xhtml"> <head> <style type="text/css"> body{ margin: 0px; } .Content { width:500px; margin:0px auto; text-align:left; padding:15px; border:1px dashed #333; background-color:#eee; } </style> </head> <body> <div class="content"> Here is the paragraph... </div> </body> </html> HTML: Center the contents in firefox but not in IE 8. I think there is some problem with auto in IE Am i right?
In your CSS, you spelt ".Content" with a capitol C. However, in your HTML, you put "<div class="content">" with a lower case C. Maybe IE doesn't know the difference, and Firefox ignores capitol/lower case letters. Try changing the capitol C to lower case and see what happens.
Use this: <!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-Type" content="text/html; charset=utf-8" /> <title>test</title> <style type="text/css"> body{ margin: 0px; } .content { width:500px; margin:0px auto; text-align:left; padding:15px; border:1px dashed #333; background-color:#eee; } </style> </head> <body> <div class="content"> Here is the paragraph... </div> </body> </html> Code (markup): Seems IE8 doesn't like rendering pages without a doctype specified at the top of the document. Oh, and when there is a doctype involved, remember that div class/ID names become case sensitive.
Just to add a DOCTYPE is a requirement for all pages to render properly, otherwise it sends IE to use quirks mode.
Thanks your code is working ... I have used these two line many time but dont know actualy whts the use of it could you explain me...
The DTD acts as a rendering mode switch. See http://www.communitymx.com/content/article.cfm?cid=85fee. cheers, gary