How to limit the width of an html site?

How to set the width of the webpage to always exactly 1000 pixels? For example, like Facebook or here on StackOverflow. The site just does not change. If the browser window is less than 1000 pixels, a scroll bar is required. And the page should be centered in the browser.

I can always place the page content inside the tags <div></div> , but I read that it will not work for all browsers. So what is the right way to do this?

+6
html
source share
2 answers

Including content in a div that has a CSS width property set to 1000px will work in different browsers.

CSS

 div.content { width: 1000px } 

HTML:

 <body> <div class="content"> ... </div> <body> 

However, consider using 960 pixels instead of 1000. This is a reliable standard that runs on most devices to the screen width of 1024 pixels, including space for scroll bars, etc.

+13
source share

Directly set to display the body with such a width:

 body { width:1000px; margin:0 auto; } 

However, I usually use a wrap div as follows:

HTML

 <body> <div class="wrap"></div> <body> </ div> <body> <div class="wrap"></div> <body> 

CSS

 div.wrap { width:1000px; margin:0 auto; } 
+4
source share

All Articles