Home >Web Front-end >Front-end Q&A >What does margin-top mean in html

What does margin-top mean in html

青灯夜游
青灯夜游Original
2021-02-22 10:55:259989browse

In HTML, margin-top means "top margin", which is a css attribute used to set the upper margin of an element; its syntax format is "margin-top:auto|length|%;" , allowing negative values ​​to be set.

What does margin-top mean in html

The operating environment of this tutorial: Windows7 system, HTML5&&CSS3 version, Dell G3 computer.

What does margin-top mean in html

CSS margin-top property

The margin-top property sets the upper margin of the element.

Note: Negative values ​​are allowed.

Syntax:

margin-top:auto|length|%|inherit;

Attribute value:

  • auto: The top margin set by the browser.

  • length: Define a fixed top margin. The default value is 0.

  • %: Defines the top margin as a percentage based on the total width of the parent object.

  • inherit: Specifies that the top margin should be inherited from the parent element.

[Recommended tutorials: CSS video tutorial, "html video tutorial"]

Example:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"> 
<style>
p.ex1 {margin-top:2cm;}
</style>
</head>

<body>

<p>一个没有指定边距大小的段落。</p>
<p class="ex1">一个2厘米上边距的段落。</p>
<p>一个没有指定边距大小的段落。</p>

</body>
</html>

Rendering:

What does margin-top mean in html

For more programming-related knowledge, please visit: Programming Video! !

The above is the detailed content of What does margin-top mean in html. 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
Previous article:Is html a software?Next article:Is html a software?