Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to limit width of html site?

Tags:

html

How do I set the width of a web page to always be exactly 1000px ? For example, like Facebook or here on StackOverflow. The site just will not resize. If the browser window is smaller than 1000px, the scroll bar is needed. And the page should be centered in the browser.

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

like image 316
Rasto Avatar asked Feb 27 '11 14:02

Rasto


People also ask

How do I limit the width of a HTML page?

Enclosing the content in a div that has the CSS width property set to 1000px will work across browsers. However, consider using 960 pixels instead of 1000. It is a reliable standard that works on most devices down to a 1024 pixel display width including space for scroll bars and such. Save this answer.


1 Answers

Enclosing the content in a div that has the CSS width property set to 1000px will work across browsers.

CSS:

div.content { width: 1000px }

HTML:

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

However, consider using 960 pixels instead of 1000. It is a reliable standard that works on most devices down to a 1024 pixel display width including space for scroll bars and such.

like image 51
Pekka Avatar answered Sep 24 '22 03:09

Pekka