Just wondering if it's legal to use "max-width" in the "body" css tag? body { max-width: 800px; } HTML: Thanks
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
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
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.
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 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.
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.