Jump to content

On Ie ..... How to center ....


Tynian

Recommended Posts

Hi ! I've a little problem.I just want to center a <div> </div> in my css, on Internet explorer.I arrived to do that with Firefox, but none also on internet explorer, can you help me please.

Link to comment
Share on other sites

margin: 0 auto;

or

text-align: center;

didn't worked?

The first one works well on firefox, but not on internet explorer, that the problem.in fact, I just want to include all the programmation code in a div and center it on my page, for the resolution.and the second, I think it would'nt work, becaouse I don't want to center text only.
Link to comment
Share on other sites

The first one  works well on firefox, but not on internet explorer, that the problem.in fact, I just want to include all the programmation code in a div and center it on my page, for the resolution.and the second, I think it would'nt work, becaouse I don't want to center text only.

for all browsers:
body{text-align: center; /* MSIE needs this */}#container{margin: 0 auto;width: 750px;text-align: left;}

so div with ID "container" is now centered with all browsers..as far as I know, there is no other way to do it with MSIE.

Link to comment
Share on other sites

This should also work also:

#page {  margin-left: auto;  margin-right: auto;}

Please note that you need any DTD on your webpages for this to work on IE. Firefox displays this correctly.

Link to comment
Share on other sites

Please note that you need any DTD on your webpages for this to work on IE. Firefox displays this correctly.
Seems as it works very well, but only if strict DTD is used with IE..But who is using transitional anyway? :)
Link to comment
Share on other sites

Seems as it works very well, but only if strict DTD is used with IE..But who is using transitional anyway? :)

I worked for me whenever I used it on a XHTML Transitional DTD page, so I assumed that it would work on all other DTDs.
Link to comment
Share on other sites

Reasons why and why not can be found in MSDN:Read The !DOCTYPE "Switch" part:http://msdn.microsoft.com/library/default....nhancements.asp :)edit:If You are using HTML transitional or frameset doctype You must use it with URL-part of DTD-tag to switch IE to "standard-compliant" mode.When Internet Explorer 6 or later is not in standards-compliant mode, it is in compatibility mode.DTD to switch IE better mode is:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">now margin: 0px auto; will work with IE6 without centering all in body-element.

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
×
×
  • Create New...