Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use HTML DOM margin attribute

Shulou Source: shulou.com Published: 2022-06-03 06:27:41 10月20日 Update

This article is to share with you about the use of HTML DOM margin attributes, the editor thinks it is very practical, so I share it with you to learn. I hope you can get something after reading this article. Let's take a look at it with the editor.

To describe the use of the HTML DOM margin attribute, the margin attribute in Html is mainly used to set the outer margin of the element.

HTML DOM margin attribute

Definition and usage

The margin property sets the outer margin of the element.

This property can use 1 to 4 values:

If you specify a value, such as div {margin:50px}-all outer margins are 50px

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

If you specify three values, such as div {margin:50px10px20px}-the top margin is 50px, the left and right margin is 10px, and the bottom margin is 20px.

If you specify four values, such as div {margin:50px10px20px30px}-the top margin is 50px, the right margin is 10px, the bottom margin is 20px, and the left margin is 30px.

Syntax:

Object.style.margin=margin

Possible values:

Example

The following example changes the margin of a paragraph:

FunctionchangeMargin () {document.getElementById ("p1") .style.margin = "100px";} script > head > Thisisaparagraphp > body > html > the above is how to use the HTML DOM margin attribute. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.

Tags: Attributes usage methods elements more knowledge articles practical three up and down two examples examples that is work meetings articles paragraphs see knowledge points industry Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info Shulou Technology MariaDB MySQL Docker