- Services
- Case Studies
- Technologies
- NextJs development
- Flutter development
- NodeJs development
- ReactJs development
- About
- Contact
- Tools
- Blogs
- FAQ
CSS margin-block-end Flexible Margin Management
Useful for flexible layouts, it adapts to different writing modes and directions.
Options include length values, auto, inherit, initial, revert, revert-layer, and unset.
Introduction
The margin-block-end CSS property sets the logical block end margin of an element, adapting to the element’s writing mode, direction, and text orientation. It’s widely supported across devices and browsers since September 2021, making it a reliable tool for creating flexible and responsive layouts.
Baseline and Compatibility
The margin-block-end property is well-supported and works across many devices and browsers since September 2021. This makes it a reliable choice for developers and designers.
Description
The margin-block-end CSS property sets the logical block end margin of an element, which adjusts based on the element’s writing mode, direction, and text orientation. This property is particularly useful for multilingual websites or applications with varying text directions.
Syntax
margin-block-end: <length> | auto | inherit | initial | revert | revert-layer | unset;Length Values
- Absolute Lengths (e.g.,
10px): Fixed units. - Relative Lengths (e.g.,
1em,5%): Relative to other elements or the viewport.
Keyword Values
auto: Automatically calculated by the browser.
Global Values
inherit: Inherits the margin from the parent element.initial: Resets to the default value.revert: Resets to the user agent’s default value.revert-layer: Resets to the value specified in the next outer layer.unset: Resets to its natural value.
Formal Definition
The margin-block-end property defines the logical block end margin of an element, adapting to the element’s writing mode, direction, and text orientation.
Initial Value
- Initial Value:
0
Applies To
- Applies To: All elements.
Inherited
- Inherited: No
Percentages
- Percentages: Depends on the layout model.
Computed Value
- Computed Value: If specified as a length, the corresponding absolute length is used. If specified as a percentage, the specified value is used. Otherwise, the value is
auto.
Animation Type
- Animation Type: A length (interpolated as real, floating-point numbers).
Formal Syntax
margin-block-end = <length-percentage> | auto | <anchor-size()>
<length-percentage> = <length> | <percentage>
<anchor-size()> = anchor-size([<anchor-element>, <anchor-size>], <length-percentage>? )
<anchor-element> = <dashed-ident>
<anchor-size> = width | height | block | inline | self-block | self-inlineExamples
Here are some practical examples to illustrate the use of the margin-block-end property in CSS.
HTML
<div> <p class="exampleText">Example text</p></div>CSS
div { background-color: yellow; width: 120px; height: 120px;}
.exampleText { margin-block-end: 20px; background-color: #c8c800;}Description: Sets a bottom margin of 20px for the paragraph.
Vertical Writing Mode
<div> <p class="exampleText">Example text</p></div>div { background-color: yellow; width: 120px; height: 120px;}
.exampleText { writing-mode: vertical-rl; margin-block-end: 20px; background-color: #c8c800;}Description: Sets a bottom margin of 20px for the paragraph, adapting to vertical text orientation.
Auto Margin
<div> <p class="exampleText">Auto margin example</p></div>div { background-color: lightblue; width: 150px; height: 150px;}
.exampleText { margin-block-end: auto; background-color: #00ccff;}Description: Automatically calculates the margin size based on the element’s context.
Inherited Margin
<div class="parent"> <div class="child">Inherited margin example</div></div>.parent { margin-block-end: 30px; background-color: lightgreen; width: 150px; height: 150px;}
.child { margin-block-end: inherit; background-color: #90ee90;}Description: The child element inherits the margin-block-end value from its parent element.
Specifications
The margin-block-end property is part of the CSS Logical Properties and Values Level 1 specification.
| Specification |
|---|
| CSS Logical Properties and Values Level 1 # margin-properties |
Browser Compatibility
The margin-block-end property is widely supported across modern browsers.
- Google Chrome: 87+
- Edge: 87+
- Firefox: 41+
- Opera: 73+
- Safari: 12.1+
Related Properties
These properties work together to manage margins in complex layouts. They are mapped to the physical margin properties:
Conclusion
The margin-block-end CSS property is a powerful tool for creating flexible and responsive layouts. It ensures that your web designs adapt seamlessly to different writing modes, directions, and text orientations. Whether you’re working on a new project or maintaining an existing one, margin-block-end is a crucial part of modern web design, allowing for more intuitive and accessible web experiences.
สร้างเว็บไซต์ 1 เว็บ ต้องใช้งบเท่าไหร่? เจาะลึกทุกองค์ประกอบ website development cost อยากสร้างเว็บไซต์แต่ไม่มั่นใจในเรื่องของงบประมาณ อ่านสรุปเจาะลึกตั้งแต่ดีไซน์, ฟังก์ชัน และการดูแล พร้อมตัวอย่างงบจริงจาก Till it’s done ที่แผนชัด งบไม่บานปลายแน่นอน
Next.js สอน 14 ขั้นตอนเบื้องต้น: สร้างโปรเจกต์แรกใน 30 นาที เริ่มต้นกับ Next.js ใน 14 ขั้นตอนเพียงแค่ 30 นาที พร้อม SSR/SSG และ API Routes ด้วยตัวอย่างโค้ดง่าย ๆ อ่านต่อเพื่อสร้างโปรเจ็กต์แรกได้ทันทีที่นี่
วิธีสมัคร Apple Developer Account เพื่อนำแอปขึ้น App Store ทีละขั้นตอน อยากปล่อยแอปบน App Store ระดับโลก มาอ่านคู่มือสมัคร Apple Developer Account พร้อมเคล็ดลับ TestFlight และวิธีอัปโหลดที่ง่ายในบทความเดียวนี้ได้เลย
TypeScript Interface คืออะไร? อธิบายพร้อมวิธีใช้และข้อแตกต่างจาก Type เรียนรู้วิธีใช้ TypeScript Interface เพื่อสร้างโครงสร้างข้อมูลที่ปลอดภัยและเข้าใจง่าย พร้อมเปรียบเทียบข้อดีข้อแตกต่างกับ Type ที่คุณต้องรู้ ถูกรวมเอาไว้ในบทความนี้แล้ว
Material-UI (MUI) คืออะไร อยากสร้าง UI สวยงามและเป็นมืออาชีพในเวลาอันรวดเร็วใช่ไหม มาทำความรู้จักกับ Material-UI (MUI) ที่ช่วยให้คุณพัฒนาแอปพลิเคชันบน React ได้ง่ายและดูดีในทุกอุปกรณ์
เปรียบเทียบ 3 วิธีติดตั้ง install node js บน Ubuntu: NVM vs NodeSource vs Official Repo แบบไหนดีที่สุด? เรียนรู้วิธีติดตั้ง Node.js บน Ubuntu ด้วย NVM, NodeSource หรือ Official Repo เลือกวิธีที่เหมาะกับความต้องการของคุณ พร้อมเปรียบเทียบ เพื่อการพัฒนาที่มีประสิทธิภาพ! พูดคุยกับซีอีโอ
We'll be right here with you every step of the way.
We'll be here, prepared to commence this promising collaboration.
Whether you're curious about features, warranties, or shopping policies, we provide comprehensive answers to assist you.