How to set the top margin in html

青灯夜游
Release: 2021-11-01 17:16:25
Original
17149 people have browsed it

htmlHow to set the top margin: 1. Use the padding-top attribute to set the top padding, the syntax is "padding-top:margin value;"; 2. Use the margin-top attribute to set the top margin, Syntax "margin-top:margin value;".

How to set the top margin in html

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

htmlSet the top margin

How to set the top margin in html

Method 1: Set the top margin

Padding refers to the space between the element border and the element content. We can use thepadding-topattribute to set the top padding of an element.

Example:

     
测试文本
测试文本
Copy after login

Rendering:

How to set the top margin in html

##Method 2: Set top margin

Margin refers to the space around the element. We can use the margin-top attribute to set the top margin of an element.

Example:

     
测试文本
测试文本
Copy after login
Rendering:

How to set the top margin in html

Recommended tutorial: "

html video tutorial"

The above is the detailed content of How to set the top margin 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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!