entry.

Internet Explorer CSS Issue: Fixed Width Container Centering

Issue

When you have a fixed with website that is centered on the page, you would normally use the margin or text-align properties like this:

#container {
	width: 750px;
	margin: 0 auto
}

However, this may not always work since IE has interesting ways of calculating margin and box model.

Internet Explorer (IE) has been well known as the most W3C incompatible browser. In particular Internet Explorer 6 (IE6), is far most the worst of its kind. Most web development jobs involving front-end design, will spend most of their debugging time on issues relating to IE6 and other IE. For a complete list of issues, see Internet Explorer CSS Issues & Solutions.

solution

To fix the problem, first center align content in the body tag then re-assign text alignment to left for the container:

body {
    text-align: center
}
 
#container {
    width: 770px;
    margin: 0 auto;
    text-align: left
}

meta.

META+ expand

Categorized under Blog Programming Knowledge and tagged with .
Posted at 02:53:3604.30.2009.
Has 1 comment, view or add a comment below.

comments.

COMMENTS+ expand


add comment.

ADD COMMENT+ expand

If you have not been here or registered before, your comment might need approval before being displayed. Please wait patiently.
E-mail field is mandatory and will never be publisized.