CSS - margin-inline-start Property
The logical inline start margin of an element is specified by the CSS property margin-inline-start. The element's writing mode, directionality, and text orientation all affect the actual physical margin.
This margin varies according to the writing-mode, direction, and text-orientation of the element; it can be margin-left, margin-top, margin-right, or margin-bottom property.
It is related to the other margins of the element, which are defined by margin-block-start, margin-block-end, and margin-inline-end.
Possible Values
The following list covers all the possible values of margin-inline-start property which are similar to margin-left property.
<length> - The fixed value of the margin's size.
<percentage> - The percentage of the margin measured in relation to the contained block's inline size, or the writing-mode defined width in a horizontal language.
auto - A percentage of the available horizontal space is allocated to the left margin, with the layout option selected playing a crucial part.
The spacing between the margin-left and margin-right values is equal when both of them are set to auto.
Applies to
All elements, except elements with table display types other than table-caption, table and inline-table. It also applies to ::first-letter.
Syntax
margin-inline-start = <'margin-top'>
CSS margin-inline-start - Length Value
The following example demonstrates the usage of margin-inline-start with length value.
<html> <head> <style> body { background-color: #F1F1F1; } #Container { height: 280px; background-color: #f5f1b8; } #Container > div { width: 150px; height: 200px; float: left; box-sizing: border-box; } .marginDemo { background-color: #e67f09; border: solid 3px #46262A; text-align: center; font-size: 20px; margin-inline-start: 25px; } .marginBox { background-color: #d7e609; border: solid 2px #46262A; text-align: center; font-size: 20px; padding: 10px; } </style> </head> <body> <h1>Explore the margin-inline-start property.</h1> <div id="Container"> <div class="marginBox">Box A</div> <div class="marginDemo"> Example of css margin-inline-start property. </div> <div class="marginBox">Box B</div> </div> </body> </html>
CSS margin-inline-start - Percentage Value
The following example demonstrates the usage of margin-inline-start with percentage value.
<html> <head> <style> body { background-color: #F1F1F1; } #Container { height: 280px; background-color: #dcdce0; } #Container > div { width: 150px; height: 200px; float: left; box-sizing: border-box; } .marginDemo { background-color: #87b9e8; border: solid 3px #46262A; text-align: center; font-size: 20px; margin-inline-start: 15%; } .marginBox { background-color: #1272cc; border: solid 3px #46262A; text-align: center; font-size: 20px; padding: 10px; } </style> </head> <body> <h1>Explore the margin-inline-start property.</h1> <div id="Container"> <div class="marginBox">Alpha</div> <div class="marginDemo"> Example of css margin-inline-start property. </div> <div class="marginBox">Beta</div> </div> </body> </html>
CSS margin-inline-start - auto and writing-mode
The following example demonstrates the usage of margin-inline-start with auto value and writing-mode: vertical-rl.
<html> <head> <style> body { background-color: #F1F1F1; } #Container { height: 280px; background-color: #dcdce0; } #Container > div { width: 150px; height: 200px; float: left; box-sizing: border-box; } .marginDemo { background-color: #d6625e; border: solid 3px #46262A; text-align: center; font-size: 20px; margin-inline-start: auto; writing-mode: vertical-rl; } .marginBox { background-color: #cc110a; border: solid 3px #46262A; text-align: center; font-size: 20px; padding: 10px; } </style> </head> <body> <h1>Explore the margin-inline-start property.</h1> <div id="Container"> <div class="marginBox">Alpha box</div> <div class="marginDemo"> Example of css margin-inline-start property. </div> <div class="marginBox">Beta box</div> </div> </body> </html>
To Continue Learning Please Login
Login with Google