1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Is this legal? body { max-width: 800px; }

Discussion in 'CSS' started by tarponkeith, Oct 16, 2007.

  1. #1
    Just wondering if it's legal to use "max-width" in the "body" css tag?

    
    body
    {
       max-width: 800px;
    }
    
    HTML:
    Thanks :)
     
    tarponkeith, Oct 16, 2007 IP
  2. jmhyer123

    jmhyer123 Peon

    Messages:
    542
    Likes Received:
    25
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Well, it probably is, but it's useless, if you just put

    
    body {
    width: 800px;
    }
    
    Code (markup):
    it does the same thing, usually you're not trying to set a max width, it's usually the min-width you're worried about ;)
     
    jmhyer123, Oct 16, 2007 IP
    tarponkeith likes this.
  3. tarponkeith

    tarponkeith Well-Known Member

    Messages:
    4,758
    Likes Received:
    279
    Best Answers:
    0
    Trophy Points:
    180
    #3
    Actually, I'm scared after seeing how messed up my site was on a widescreen... I'm not really a fan of setting the exact width, as I know a lot of people surf in smaller windows or with their bookmarks tab open (as i do) :)

    thanks for the reply
     
    tarponkeith, Oct 16, 2007 IP
  4. Crimsonc

    Crimsonc Peon

    Messages:
    616
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #4
    put your design in a container div and give that a max width.
     
    Crimsonc, Oct 17, 2007 IP
  5. soulscratch

    soulscratch Well-Known Member

    Messages:
    964
    Likes Received:
    45
    Best Answers:
    0
    Trophy Points:
    155
    #5
    What Crimsonc said. Something tells me the body will NOT be limited to only 800 pixels.. I would imagine you could use it as a wrapper but if you set a background color it would still span the entire viewport similar to the html{} element. I could be wrong.
     
    soulscratch, Oct 17, 2007 IP
    tarponkeith likes this.
  6. Dan Schulz

    Dan Schulz Peon

    Messages:
    6,032
    Likes Received:
    436
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Yes, you can use it on the body element. Just understand that IE 6 won't understand max-width, and that if you want to support IE 5/6, you'll have to use an expression (or an external JavaScript function call) and that IE 5.x will require the container DIV that the others have suggested.
     
    Dan Schulz, Oct 17, 2007 IP
  7. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,998
    Best Answers:
    253
    Trophy Points:
    515
    #7
    Dan pointed out most of the details like it WILL work in modern browsers, IE 5.x will flat out ignore it, and of course IE 6 and earlier lack min-width.

    But jmhyer123 it is NOT the same thing. If the user sets the screen width to 640px (like a 1280 user who doesn't run the browser full screen, or someone browsing from a CE mobile device) it will shrink to that size.
     
    deathshadow, Oct 18, 2007 IP
  8. ChaosFoo

    ChaosFoo Peon

    Messages:
    232
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #8
    This is exactly what I would recommend. If you set a max-width on the body, not all browsers are going to display it correctly. I tried this once, and ran into problems. Unfortunately, I can't remember the exact details, but I do remember wrapping the entire page in a <div> and giving that a max-width, and it worked beautifully.

    Do you have a link to the site you are working on? You've posted a couple of questions about it, and now you have my curiosity piqued. :)
     
    ChaosFoo, Oct 18, 2007 IP