How to center CSS in IE and FF--experience exchange

Source: Internet
Author: User
ie method: <body style= "Text-align:center;" >
The content within the <body> tag is centered.
Non ie method: <div style= "Margin-left:auto;margin-right:auto;" ></div>
<div> the left and right margins of the mark are automatically adapted to achieve the center effect.
The standard recommended CSS use method is the latter, IE's set of non-standard.
However, using the standard DTD declaration (XHTML version) in IE6, you can also use the margin:0 auto method to achieve the center effect.
<! 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" > <pead> <style type= "Text/css" >. ie {text-align:center; widt h:100%; /* IE Center/* IE Div {width:200px border:solid 1px #999;} . PR {margin:0 auto; width:200px border:solid 1px #f00}/* Standard center/</style> <title> Center </title> < /head> <body> <div class= "ie" > <div>ie center </div> </div> <pr/> <div clas s= "PR" > Standard center </div> </body> </ptml>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.