What does margin-top mean in html

青灯夜游
Release: 2023-01-03 09:24:18
Original
9959 people have browsed it

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;
Copy after login

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>
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template