Home >Web Front-end >CSS Tutorial >What does margin-top mean?
margin-top is a property in CSS, used to set the top margin of an element. All mainstream browsers support the margin-top property. Let’s take a brief look at the usage of the margin-top property.
The syntax of margin-top is as follows:
margin-top:value
The value of value has the following possibilities:
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 height of the parent object.
inherit: Specifies that the top margin should be inherited from the parent element.
Let’s take a look at a simple code example:
<html> <head> <style type="text/css"> p.topmargin {margin-top: 5cm} </style> </head> <body> <p>这个段落没有指定外边距。</p> <p class="topmargin">这个段落带有指定的上外边距。</p> </body> </html>
The running results are as follows:
This article is all over here For more exciting content, you can pay attention to the CSS Video Tutorial column on the PHP Chinese website! ! !
The above is the detailed content of What does margin-top mean?. For more information, please follow other related articles on the PHP Chinese website!