


css details review notes--padding, borders and margins_html/css_WEB-ITnose
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.

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

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











The roles of HTML, CSS and JavaScript in web development are: 1. HTML defines the web page structure, 2. CSS controls the web page style, and 3. JavaScript adds dynamic behavior. Together, they build the framework, aesthetics and interactivity of modern websites.

The future trends of HTML are semantics and web components, the future trends of CSS are CSS-in-JS and CSSHoudini, and the future trends of JavaScript are WebAssembly and Serverless. 1. HTML semantics improve accessibility and SEO effects, and Web components improve development efficiency, but attention should be paid to browser compatibility. 2. CSS-in-JS enhances style management flexibility but may increase file size. CSSHoudini allows direct operation of CSS rendering. 3.WebAssembly optimizes browser application performance but has a steep learning curve, and Serverless simplifies development but requires optimization of cold start problems.

The future of HTML is full of infinite possibilities. 1) New features and standards will include more semantic tags and the popularity of WebComponents. 2) The web design trend will continue to develop towards responsive and accessible design. 3) Performance optimization will improve the user experience through responsive image loading and lazy loading technologies.

The roles of HTML, CSS and JavaScript in web development are: HTML is responsible for content structure, CSS is responsible for style, and JavaScript is responsible for dynamic behavior. 1. HTML defines the web page structure and content through tags to ensure semantics. 2. CSS controls the web page style through selectors and attributes to make it beautiful and easy to read. 3. JavaScript controls web page behavior through scripts to achieve dynamic and interactive functions.

HTML is the cornerstone of building web page structure. 1. HTML defines the content structure and semantics, and uses, etc. tags. 2. Provide semantic markers, such as, etc., to improve SEO effect. 3. To realize user interaction through tags, pay attention to form verification. 4. Use advanced elements such as, combined with JavaScript to achieve dynamic effects. 5. Common errors include unclosed labels and unquoted attribute values, and verification tools are required. 6. Optimization strategies include reducing HTTP requests, compressing HTML, using semantic tags, etc.

HTML, CSS and JavaScript are the core technologies for building modern web pages: 1. HTML defines the web page structure, 2. CSS is responsible for the appearance of the web page, 3. JavaScript provides web page dynamics and interactivity, and they work together to create a website with a good user experience.

HTMLisnotaprogramminglanguage;itisamarkuplanguage.1)HTMLstructuresandformatswebcontentusingtags.2)ItworkswithCSSforstylingandJavaScriptforinteractivity,enhancingwebdevelopment.

HTML is a language used to build web pages, defining web page structure and content through tags and attributes. 1) HTML organizes document structure through tags, such as,. 2) The browser parses HTML to build the DOM and renders the web page. 3) New features of HTML5, such as, enhance multimedia functions. 4) Common errors include unclosed labels and unquoted attribute values. 5) Optimization suggestions include using semantic tags and reducing file size.
