CSS Logical Properties for RTL
Support bidirectional text layouts using CSS logical properties like margin-inline and padding-block for internationalization.
Code
.card {
padding-inline: 1rem;
padding-block: 0.5rem;
margin-inline-start: auto;
border-inline-start: 2px solid #4f46e5;
}
[dir="rtl"] .icon {
transform: scaleX(-1);
}CSS Logical Properties for RTL
Support bidirectional text layouts using CSS logical properties like margin-inline and padding-block for internationalization.
Code
.card {
padding-inline: 1rem;
padding-block: 0.5rem;
margin-inline-start: auto;
border-inline-start: 2px solid #4f46e5;
}
[dir="rtl"] .icon {
transform: scaleX(-1);
}
Explanation
margin-inline and padding-block map to physical sides according to the writing mode, so one stylesheet serves both left-to-right and right-to-left text. Expected behavior: in RTL the inline edges flip automatically. Constraint: logical properties only flip when the inherited direction or writing-mode changes; hard-coded physical values will not.
Interactive Tools for This Topic
Properties File ParserParse Java .properties files with comments, continuations, separators, and escapes, then emit clean JSON.Aspect Ratio CalculatorSimplify a width-to-height ratio, show its decimal value, and derive a matching height for a new width.Border Radius PreviewPreview four-corner border-radius values on a live box and copy the generated shorthand border-radius CSS declaration.Box Shadow GeneratorBuild CSS box-shadow values with offset, blur, spread, color, opacity, and inset controls, with a live preview of the result.
Report a problem with this exampleOpens a pre-filled issue on GitHub.