Get the App
SLTechnology News&Howtos  ›  Development  › 

Definition and usage of HTML DOM padding attribute

Shulou Source: shulou.com Published: 2022-06-03 06:27:48 11月17日 Update

This article shows you the definition and usage of the HTML DOM padding attribute, which is concise and easy to understand, which will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.

Focus on the use of the HTML DOM padding attribute, which is mainly used to set the inner margin of the element, which defines the space between the element border and the content of the element.

HTML DOM padding attribute

Definition and usage

The padding property sets the inner margin of the element.

The padding attribute defines the space between the element border and the element content.

This property can take four values:

If you specify a value, such as div {padding: 50px}-the padding on all four sides is 50px.

If you specify two values, such as div {padding: 50px 10px}-the upper and lower inner margin is 50px, and the left and right inner margin is 10px.

If you specify three values, such as div {padding: 50px 10px 20px}-the upper inner margin is 50px, the left and right inner margin is 10px, and the lower inner margin is 20px.

If you specify four values, such as div {padding: 50px 10px 20px 30px}-the upper inner margin is 50px, the right inner margin is 10px, the lower inner margin is 20px, and the left inner margin is 30px.

Syntax:

Object.style.padding=paddingPossible Values

Possible Values

Example

This example changes the inner margin of the element:

P {border: thin dotted # FF0000;} function changePadding () {document.getElementById ("p1") .style.padding = "2cm";}

Tags: Attributes elements content between skills knowledge space borders concise concise three up and down two examples that is articles more articles industries grammar Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn Linux OPPO Reno Huawei NVidia