Home  >  Article  >  Web Front-end  >  How to use css height attribute

How to use css height attribute

silencement
silencementOriginal
2019-05-27 16:25:393495browse

How to use css height attribute

css height attribute definition and usage

In css, the height attribute is used to set the height of an element, excluding padding and borders. Or page margins, which can add padding, borders, and margins outside the content area. Inline non-replaced elements ignore this attribute.

The height attribute is used a lot and is a commonly used attribute in CSS. When you need to set the height of an element, you can use this attribute to achieve it. If you need to set the width of an element, we can use the width attribute to do so. The height attribute and the width attribute are often used together to control the size of an element.

css height attribute syntax format

css syntax: height:auto/length/%/inherit;

JavaScript syntax: object.style.height ="50px";

css height attribute value description

auto: default value, the browser will calculate the actual height;

length: use Units such as px and cm define the height;

%: based on the percentage height of the block-level object that contains it;

inherit: specifies that the value of the height attribute should be inherited from the parent element

Example





css height属性设置元素的高度



div1
div2
div3

Running result

How to use css height attribute

The above is the detailed content of How to use css height attribute. 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