In
html, you can use the max-width attribute to set the maximum width. Just use the style attribute to add the "max-width:length|%" style to the element; the value "length" can define a fixed size. Maximum width; '%' defines the maximum width as a percentage of the block-level object containing the element.
The operating environment of this tutorial: Windows 7 system, CSS3&&HTML5 version, Dell G3 computer.
The max-width attribute sets the maximum width of the element.
Note: The max-width attribute does not include padding, borders, or margins!
Attribute value:
Value | Description |
---|---|
none | default. The definition places no limit on the maximum width of the element. |
length | Define the maximum width value of the element. |
% | Defines the maximum width based on a percentage of the block-level object that contains it. |
Example:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> </head> <body> <textarea>文本框默认宽度</textarea><br> <textarea style="max-width: 400px;">文本框最大宽度400px</textarea> </body> </html>
Rendering:
(Learn Video sharing: css video tutorial)
The above is the detailed content of How to set the maximum width in html. For more information, please follow other related articles on the PHP Chinese website!