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

What does margin mean in html

Sep 13, 2021 pm 04:26 PM
css html margin

In HTML, margin means "margin", which refers to the blank area surrounding the border of an element; setting margins will create additional "blank" outside the element, allowing the space between the boxes to There is a "blank" distance. To set margins, you need to use the css margin property, which accepts any length unit, percentage value, or even negative value.

What does margin mean in html

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

In HTML, margin means "margin", which refers to the blank area surrounding the border of an element.

Setting margins will create additional "whitespace" outside the element, allowing a "whitespace" distance between boxes.

The easiest way to set margins is to use the margin property, which accepts any length unit, percentage value, or even negative value.

The margin property accepts any length unit, which can be pixels, inches, millimeters, or ems.

margin can be set to auto. A more common approach is to set a length value for the margins. The following declaration sets 1/4-inch-wide margins on each side of the h1 element:

h1 {margin : 0.25in;}
Copy after login

The following example defines different margins for the four sides of the h1 element, using the length units It is pixels (px):

h1 {margin : 10px 0px 15px 5px;}
Copy after login

Same as the setting of the padding. The order of these values ​​​​is starting from the top margin (top) and rotating clockwise around the element:

margin: top right bottom left
Copy after login

In addition , you can also set a percentage value for margin:

p {margin : 10%;}
Copy after login

The percentage is calculated relative to the width of the parent element. The example above sets the margins for the p element to 10% of the width of its parent element.

The default value of margin is 0, so if a value is not declared for margin, no margin will appear. However, in practice, browsers already provide predetermined styles for many elements, and margins are no exception. For example, in browsers that support CSS, margins create "empty lines" above and below each paragraph element. Therefore, if no margin is declared for the p element, the browser may apply one on its own. Of course, as long as you specifically declare it, the default style will be overridden.

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

The above is the detailed content of What does margin mean in html. For more information, please follow other related articles on the PHP Chinese website!

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
Two Point Museum: All Exhibits And Where To Find Them
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to achieve gap effect on the card and coupon layout with gradient background? How to achieve gap effect on the card and coupon layout with gradient background? Apr 05, 2025 am 07:48 AM

Realize the gap effect of card coupon layout. When designing card coupon layout, you often encounter the need to add gaps on card coupons, especially when the background is gradient...

The style remains the same after PC page zooms: What are the possible solutions? The style remains the same after PC page zooms: What are the possible solutions? Apr 05, 2025 am 07:51 AM

The challenge of keeping the style of the page zoomed and the same after the page is zoomed in. Many developers will encounter a difficult problem when making PC pages: when the user zooms in or out of the browsing...

How to implement a custom height layout with 2:5:3 scale and adapt to different resolutions using CSS Flexbox? How to implement a custom height layout with 2:5:3 scale and adapt to different resolutions using CSS Flexbox? Apr 05, 2025 am 07:45 AM

Using CSS to achieve custom height and adapt to layouts with different resolutions This article will explore how to use CSS to achieve a custom height layout with a scale of 2:5:3 and...

What exactly is the merge of CSS vertical margins? What exactly is the merge of CSS vertical margins? Apr 05, 2025 am 09:12 AM

In-depth understanding of CSS vertical margin merging In CSS style design, vertical margin merging is a common problem, which refers to adjacent block-level elements...

How to adapt and adjust the label size of the Element-UI horizontal menu el-menu on the PC and mobile side? How to adapt and adjust the label size of the Element-UI horizontal menu el-menu on the PC and mobile side? Apr 05, 2025 am 10:12 AM

The adaptation issues of the Element-UI menu component el-menu and label size adjustment During the development process of using the Element-UI framework, the flexibility and ease of use of the el-menu component...

How to solve the problem of page jitter caused by dynamically setting elements to fixed in JavaScript? How to solve the problem of page jitter caused by dynamically setting elements to fixed in JavaScript? Apr 05, 2025 am 11:39 AM

How to solve the problem of page jitter caused by dynamically setting elements to fixed by JS. When dynamically setting elements to fixed by JavaScript, you sometimes encounter page jitter...

Under a fixed width layout, what is the relationship between the font size and the letter width? Under a fixed width layout, what is the relationship between the font size and the letter width? Apr 05, 2025 pm 12:51 PM

Under fixed width layout, the subtle relationship between font size and letter width When designing web pages, we often encounter the need to line up in fixed width containers...

See all articles