Jump to content

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


Recommended Posts

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 post
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 post
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 post
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 post
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 post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...