In HTML, you can use the height attribute and width attribute to set the size. You only need to set the "height: length value" and "width: length value" styles to the element; the unit of the length value can be px, cm, etc., or "%" based on the percentage height of the block-level object containing it.
The operating environment of this tutorial: Windows7 system, CSS3&&HTML5 version, Dell G3 computer.
In CSS, you can often set the size of HTML elements in pixels. This method is often used in the actual development process. For example, use pixels to set the width and height of an image.
In CSS, you can also use percentages to set the size of elements. This method is often used when the element is displayed in proportion to the window. used. For example, use percentages to set the width and height of an image.
In CSS, you can also use centimeters to set the size of elements. This method often requires that the size of the element differs from the actual size. Used when printing sizes are consistent. For example, use centimeters to set the image's width and height.
In CSS, you can also use rem as the unit to define the size of the element. This unit is commonly used when making mobile web pages. , the elements set by this unit will change as the size of the display window changes. For example, use rem to set the width and height of an image.
CSS sets the maximum width of HTML elements. Set the maximum width of the element through max-width. When the window is large enough to display the element, it will be limited by the maximum width. If the height is not set, the height is the adaptive height.
CSS sets the maximum height of HTML elements. Set the maximum height of the element through max-height. When the display window is high enough, the height of the element will be limited by this height. When no width is set, the width is adaptive.
CSS sets the size of HTML elements, and there is also a method of setting line-height (line-height), which is generally the setting of the line-height of text content.
Recommended learning: html video tutorial
The above is the detailed content of How to set the size of html. For more information, please follow other related articles on the PHP Chinese website!