Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

How to center content in IE?

Featured Replies

Is there any way to center content in IE besides using this code:

 

body {
   text-align:center;
}

Maybe this:

 

<div style="width:600px; margin:0 auto;">

Content in the middle here

</div>

 

Is that what you mean?

 

 

Ahhh inline styling evil evil....

 

 

Have you looked at the tutorial that I have written?

 

http://www.webdesignerforum.co.uk/index.php?showtopic=2473

 

 

and why don't you want to use text-align:center? whats wrong with it?

What is the problem you're having exactly? If it is a specific problem it may be worth explaining. Ppl may be more able to post some help then??

 

i have been doing a lot of reading recently about padding, margins and negative margins which have helped a lot with alignment for me.

 

All the best :)

Which version of IE are you talking about? IE6 and above can be centred using e.g. width:800px; margin:0 auto; - but you must use a strict doctype to force standards mode.

To center content you can use two ways:

 

body {
margin-left:auto;
margin-right:auto;
}

 

or

 

body {
margin: 0 auto;
}

...this would be the same for every browser.

 

It's true this won't work unless you have a valid doctype declaration, etc. Search Google for "XHTML tutorial" :).

  • 3 weeks later...
  • Author

Sorry, I forgot about this topic.

 

Maybe this:

 

<div style="width:600px; margin:0 auto;">

Content in the middle here

</div>

 

Is that what you mean?

 

Little James

 

Thanks little james!

 

 

Ahhh inline styling evil evil....

 

 

Have you looked at the tutorial that I have written?

 

http://www.webdesignerforum.co.uk/index.php?showtopic=2473

 

 

and why don't you want to use text-align:center? whats wrong with it?

 

Yup, I'm strongly against inline styling. All my websites are coded XHTML 1.0 Strict if I can help it.

 

 

What is the problem you're having exactly? If it is a specific problem it may be worth explaining. Ppl may be more able to post some help then??

 

i have been doing a lot of reading recently about padding, margins and negative margins which have helped a lot with alignment for me.

 

All the best :)

 

Yup. Actually All I really wanted to know was if there was any other way. I'm cool with just text-align though.

 

 

Which version of IE are you talking about? IE6 and above can be centred using e.g. width:800px; margin:0 auto; - but you must use a strict doctype to force standards mode.

 

IE6, IE7.

 

To center content you can use two ways:

 

body {
margin-left:auto;
margin-right:auto;
}

 

or

 

body {
margin: 0 auto;
}

...this would be the same for every browser.

 

It's true this won't work unless you have a valid doctype declaration, etc. Search Google for "XHTML tutorial" :).

 

Thanks for the information.

/* centre content - cross browser compatible */

body {

text-align: center;

}

#container {

margin: 0 auto;
width: 930px;

}

 

This way you can place all your content inside a container with <div id="container"> and it has the added bonus that it will fit perfectly inside a 1024 browser window.

 

See this website, this one uses that exact method:

 

www.switchfinance.co.uk

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.