SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Enthusiast
    Join Date
    Nov 2007
    Posts
    35
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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!

  2. #2
    masquerading Nick's Avatar
    Join Date
    Jun 2003
    Location
    East Coast
    Posts
    2,215
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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:

    Code:
    <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.
    Nick . all that we see or seem, is but a dream within a dream
    Show someone you care, send them a virtual flower.
    Good deals on men's watches

  3. #3
    SitePoint Addict jemple's Avatar
    Join Date
    Dec 2008
    Posts
    291
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Its a way of controlling the overall width and dimensions of a page by wrapping it in a 'container'.

  4. #4
    SitePoint Enthusiast
    Join Date
    Nov 2007
    Posts
    35
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    icic, thanks. this is useful!

  5. #5
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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.
    Birnam wood is come to Dunsinane

  6. #6
    SitePoint Wizard webcosmo's Avatar
    Join Date
    Oct 2007
    Location
    Boston, MA
    Posts
    1,480
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by AutisticCuckoo View Post
    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.

  7. #7
    SitePoint Wizard bronze trophy Black Max's Avatar
    Join Date
    Apr 2007
    Posts
    4,029
    Mentioned
    12 Post(s)
    Tagged
    0 Thread(s)
    Does

    Code:
    <center></center>
    work in strict doctypes any longer?

  8. #8
    SitePoint Wizard bronze trophy Tyssen's Avatar
    Join Date
    Oct 2005
    Location
    Brisbane, QLD
    Posts
    4,067
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It'll work but was deprecated with HTML 4 so shouldn't be used - that's what CSS is for.

  9. #9
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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.
    Birnam wood is come to Dunsinane


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •