max-width

Browser Internet Explorer Netscape Opera Safari Firefox
Version 5.5 6.0 7.0 8.0 8.0 9.0 7.0 8.0 9.2 9.5 1.3 2.0 3.1 1.5 2.0 3.0
Supported No No Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes

Short information
CSS CSS2
Default value No
Inherited No
Applied To all elements except built-in elements and tables
HTML analog No
Reference to specification http://www.w3.org/TR/CSS21/visudet.html#propdef-min-width

Description
This argument determines the maximum width of an element. Value of element width will be calculated depending on the determined parameters width, max-width and min-width. In tab. 1 it is shown what the browser uses at concurrent use of the specified properties.

Table 1. Element width
Parameters values Width
min-width < width < max-width width
width < max-width width
width > max-width max-width
min-width > width > max-width min-width
min-width > width < max-width min-width

This table data means following: if width value (width) is more than value max-width the element width is accepted equal to the value max-width.

Syntax

max-width: value

Arguments
Pixels (px) and percent (%) are accepted as values

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
 <head>
  <meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
  <title>Версия сайта для КПК</title>
  <style type="text/css" media="handheld">
   body {
    max-width: 320px; /* Max page width in pixels */ 
   }
  </style>
 </head>
 <body>
  <h1>Title text</h1>
  <p>Example text</p>
 </body>
</html>

In this example the page width is limited to 320 pixels for all palm gadgets (palm pocket computers, smartphones and other gadgets able to image HTML-documents).

Object model

[window.]document.getElementById("elementID").style.maxWidth
Form Creator
Form Builder
PHP Form
Web Forms