Why do most developers put <div id = "wrapper"> firstly?

Why do most developers put this div wrapper on most of their websites?

I don’t know what’s the point, please tell me why!

A lot of sites don’t span the full screen length (i.e. fixed width sites), so webmasters use a “wrapper” to set the appropriate width and act as a full screen would. Something I do from time to time:

<html>
<head>
<title>blah</title>
<style type="text/css">
#wrapper {
  text-align: left;
  width: 760px; }
</style>
</head>

<body>

<center>

<div id="wrapper">main html here</div>

</center>

</body>
</html>

Not a perfect example but it gets the point across. It’s probably bad practice to include all the page HTML in between <center> tags.

Its a way of controlling the overall width and dimensions of a page by wrapping it in a ‘container’.

icic, thanks. this is useful!

I think it’s primarily because Internet Explorer (version 7 and older) have a number of annoying and frustrating bugs when it comes to styling the body element. Therefore you need an extra container around the whole content if you want to, e.g., centre the page or specify min/max width constraints on it.

very right. for example text-align:center; on IE would give a annoying horizontal scorllbar although places the content in center.

Does

<center></center>

work in strict doctypes any longer?

It’ll work but was deprecated with HTML 4 so shouldn’t be used - that’s what CSS is for.

Yes, it will work in browsers that support <center>. Browsers don’t care what doctype you use (other than to choose between quirks mode and standards mode). If they support <font> and <center> those tags will work even if you declare the doctype as Strict.

They are deprecated for a reason, though. As Tyssen said, that’s what CSS is for.