Home >Web Front-end >Front-end Q&A >How to set the maximum width in html

How to set the maximum width in html

青灯夜游
青灯夜游Original
2021-05-13 17:49:237743browse

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.

How to set the maximum width in html

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:

How to set the maximum width in html

(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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:What does css do?Next article:What does css do?