


The padding, border, and margin properties of an element affect how the entire document is laid out, and more importantly, they can heavily affect the appearance of a given element.
Height and Width
These two attributes cannot be applied to inline non-replaced elements, whose height and width are determined by the content of the link, not by the author. Elements in normal flow rarely have a set height.
Margins and padding
If the element has a background, it will affect the use of padding and margins, because the background will extend into the padding, But it won't extend to the margins. The padding and margins specified for an element affect when the element's background ends.
Add 10 pixels of margin to each side of the content area, margin: 10px, similar to HTML's hspace and vspace, set an extra space around the image. Margin follows the following pattern:
margin: top right bottom left. The values rotate clockwise around the element from top to bottom. If you want to get the effect you want, you have to order the values correctly. When one of the values is defaulted, the following rules will be followed:
1) If the value of the left margin is missing, the value of the right margin will be used.
2) If the value of the bottom margin is missing, the value of the top margin is used.
3) If the value of the right margin is missing, the value of the top margin is used.
In other words, if you specify 3 values for margin, the 4th value will be copied from the 2nd one. If two values are given, the 4th value will be copied from the 2nd value, and the 3rd value will be copied from the 1st value.
Single-sided margin attribute , for margin:auto auto auto 3em; equivalent to margin-left:3em; you can use a single margin-top, margin-right, margin-bottom and margin-left single setting margin.
The rules of "negative margins and merged margins" were discussed in the previous section: the margins of vertically adjacent block-level elements will be merged in normal flow. But when margins are applied to inline non-replaced elements, they have no effect on line height. Since margins are actually transparent, this declaration has no visual effect, since margins on inline non-replaced elements do not change an element's line height.
But note that there is an extra space between the end of the word before the inline non-replaced element and the border of the inline element's background. If you like, you can add this extra space to both ends of the inline element:
<p style="font-size:12px;line-height:14px;"> This is text<em>some of which emphasized</em>,plus other text<br>which id <strong style ="margin:25px;background:silver">strongly emphasized</strong>and which is<br>larger than the surrounding text. </p>
The effect is as follows:
If the inline element is not Things get more interesting by replacing the element with negative margins. The top and bottom margins of the element are not affected, nor is the line height, but the left and right ends of the element may overlap other content.
Replaced elements are different: the margins set for the replaced element do affect the line height, possibly making it increase or decrease depending on the value of the top and bottom margins. The left and right margins of an inline replacement element have the same effect as the left and right margins of the replacing element.
Border
Every border has 3 aspects: its width or thickness, its style or appearance, and its color. The default style of the border is none, and the border may not be visible. The default border color is the foreground color of the element itself, if no color is declared for the border it will be the same as the element text color.
Border style
If a border has no style, it will have no width, but in some cases you may want to create an invisible one frame. This introduces the border color transparent, which is used to create invisible borders with width. This transparent border acts as padding, so the element's background extends into the border area (assuming there is a visible background).
Percent value and padding
You can set a percentage value for the padding of an element. As with outer margins, percentage values are calculated relative to the width of their parent element, so if the width of the parent element changes, they will change.
Note that the top and bottom padding are consistent with the left and right padding; that is, the top and bottom padding will be calculated relative to the width of the parent element, not relative to the height.

The article discusses the HTML <datalist> element, which enhances forms by providing autocomplete suggestions, improving user experience and reducing errors.Character count: 159

The article discusses the HTML <progress> element, its purpose, styling, and differences from the <meter> element. The main focus is on using <progress> for task completion and <meter> for stati

The article discusses the HTML <meter> element, used for displaying scalar or fractional values within a range, and its common applications in web development. It differentiates <meter> from <progress> and ex

The article discusses the <iframe> tag's purpose in embedding external content into webpages, its common uses, security risks, and alternatives like object tags and APIs.

The article discusses the viewport meta tag, essential for responsive web design on mobile devices. It explains how proper use ensures optimal content scaling and user interaction, while misuse can lead to design and accessibility issues.

The article discusses using HTML5 form validation attributes like required, pattern, min, max, and length limits to validate user input directly in the browser.

Article discusses best practices for ensuring HTML5 cross-browser compatibility, focusing on feature detection, progressive enhancement, and testing methods.

This article explains the HTML5 <time> element for semantic date/time representation. It emphasizes the importance of the datetime attribute for machine readability (ISO 8601 format) alongside human-readable text, boosting accessibilit


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.
