How to set the top margin by html
This article mainly introduces how to set the upper margin of html, which is very detailed and has certain reference value. Friends who are interested must finish reading it!
Html sets the upper margin: 1, use the padding-top attribute to set the upper margin, syntax "padding-top: margin value;"; 2, use the margin-top property to set the upper margin, syntax "margin-top: margin value;".
The operating environment of this tutorial: windows7 system, CSS3&&HTML5 version, Dell G3 computer.
Html sets the top margin
Method 1: set the upper inner margin
The inner margin refers to the space between the element border and the content of the element. We can use the padding-top attribute to set the upper inner margin of the element.
Example:
Div {border: 1px solid red;} .box {padding-top: 20px;} Test text
Effect picture:
Method 2: set the upper outer margin
The outer margin refers to the space around the element. We can use the margin-top attribute to set the top margin of the element.
Example:
Div {border: 1px solid red;} .box {margin-top: 20px;} Test text
Effect picture:
The above is all the content of the article "how to set the top margin in html". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!