CSS Portal

CSS Logical Properties Converter

Physical properties like margin-left and padding-top are anchored to screen edges - they break in RTL languages like Arabic and Hebrew, or vertical writing modes like Japanese. Logical properties replace fixed directions with flow-relative equivalents that adapt automatically.

Paste your CSS, click Convert, and get every physical property mapped to its logical counterpart - with syntax highlighting, line numbers, and per-line revert control.

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong!
CSS Logical Properties Converter
Your CSS - paste or drag & drop a .css file
Some conversions are worth reviewing. Properties like width, height, text-align, and float have logical equivalents that behave differently across writing modes - they are highlighted in amber. Hover any highlighted line to revert it; it turns green when reverted so you can track your changes.
Converted output - hover a line to revert it
Your converted CSS will appear here

Understanding the model

Block axis & Inline axis - visualised

CSS logical properties are built on two flow-relative axes. Understanding which axis maps to which screen direction in each writing mode is the key to using them confidently.

Horizontal LTR direction: ltr
block-start block-end ↕ block axis inline-start inline-end margin-inline-start = margin-left ✓ margin-block-start = margin-top ✓
Horizontal RTL direction: rtl
block-start block-end inline-start inline-end margin-inline-start = margin-right ✓ margin-block-start = margin-top ✓
Vertical RL writing-mode: vertical-rl
block-start block-end inline-start inline-end inline-size = height block-size = width axes swap in vertical mode!
Interactive
Writing Mode Simulator
Physical properties direction: ltr
element
margin-left margin-right margin-top margin-bottom
margin-left: 24px; margin-top: 16px;
Logical properties direction: ltr
element
margin-inline-start margin-inline-end margin-block-start margin-block-end
margin-inline-start: 24px; margin-block-start: 16px;
What are CSS logical properties?

CSS logical properties define layout relative to a document's block flow direction and inline direction, rather than physical screen edges. Standardised in the CSS Logical Properties Level 1 spec, they allow the same CSS to work correctly across any writing system.

In a standard horizontal LTR document, logical and physical properties map identically. The difference emerges when direction or writing-mode changes - logical properties automatically adapt, physical ones stay fixed to screen edges.

Why they matter for modern CSS

Internationalisation: Over 600 million people use RTL languages. Physical properties need duplicate rules under [dir="rtl"]. Logical properties eliminate that overhead - the browser handles mirroring automatically.

Vertical writing modes: In writing-mode: vertical-rl, physical width and height swap meaning. Logical inline-size and block-size remain semantically correct regardless.

Component libraries: Logical properties mean shared components work in any locale out of the box, without consumers needing to override directional styles.

Full conversion reference

Every mapping this tool applies. Entries marked ⚠ Review are highlighted in the output.

Physical Logical
Margin
margin-top margin-block-start
margin-bottom margin-block-end
margin-left margin-inline-start
margin-right margin-inline-end
Margin Shorthands
margin: a b c d margin-block: a c; margin-inline: d b ⚠ Review
margin: a b margin-block: a; margin-inline: b
Padding
padding-top / padding-bottom / padding-left / padding-right padding-block-start / padding-block-end / padding-inline-start / padding-inline-end
Padding Shorthands
padding: a b c d padding-block: a c; padding-inline: d b ⚠ Review
padding: a b padding-block: a; padding-inline: b
Border
border-top / border-bottom / border-left / border-right border-block-start / border-block-end / border-inline-start / border-inline-end
Border Radius
border-top-left-radius border-start-start-radius
border-top-right-radius border-start-end-radius
border-bottom-left-radius border-end-start-radius
border-bottom-right-radius border-end-end-radius
Sizing
width / height / min-width / max-width inline-size / block-size / min-inline-size / max-inline-size ⚠ Review
Positioning
top / bottom / left / right inset-block-start / inset-block-end / inset-inline-start / inset-inline-end
Text, Float, Overflow
text-align: left/right text-align: start/end ⚠ Review
float / clear: left/right float / clear: inline-start/end ⚠ Review
overflow-x / overflow-y overflow-inline / overflow-block
Review guidance - when to keep the original

width and height: Equivalent in horizontal writing modes but swap meaning in vertical ones. Keep physical sizing for elements deliberately sized relative to screen edges - overlays, fixed sidebars, images.

text-align: left/right: Use start/end when text should follow the natural inline direction. Keep left/right when text must be pinned to a specific physical edge regardless of locale.

Multi-value shorthands: The converter expands margin: a b c d into margin-block and margin-inline shorthands. Always visually verify these - value order conventions differ.

Browser support

All major logical properties are well supported in Chrome, Firefox, Safari, and Edge since 2019–2021. The newer overflow-inline/block and logical border-radius variants are supported in all current browser versions.

For older browser support, declare the physical property first as a fallback, then the logical property - browsers that don't understand logical properties ignore it gracefully.

FAQ
How does shorthand conversion work?

For two-value shorthands like margin: 16px 24px, the converter maps the first value (block axis) to margin-block and the second (inline axis) to margin-inline. Four-value shorthands like margin: 10px 20px 30px 40px (top right bottom left) become margin-block: 10px 30px; margin-inline: 40px 20px. Single-value shorthands pass through unchanged since they already apply equally to all sides.

Will converting break my existing LTR-only layout?

No. In a standard horizontal LTR document, logical properties are functionally identical to their physical counterparts. The difference only manifests when direction or writing-mode changes.

What does the writing mode simulator show?

It shows the same element with physical vs. logical margin properties applied, in LTR, RTL, and vertical-rl writing modes. Physical margins stay fixed to screen edges; logical margins follow the text flow direction - which is exactly the difference you want when building internationalised UIs.

Can I revert everything at once?

Click any converted (blue) line to revert it individually, or click a reverted (amber) line to restore it. To start over completely, click Clear and re-paste your CSS.

What are CSS logical properties?

CSS logical properties define layout relative to a document's block flow direction and inline direction, rather than physical screen edges like top, left, right, and bottom. Instead of margin-left, you write margin-inline-start; instead of padding-top, you write padding-block-start. Because they are flow-relative, they automatically adapt when the writing direction changes - for example in RTL languages like Arabic and Hebrew, or vertical writing modes like Japanese - without any extra overrides in your CSS.

What is the difference between the block axis and the inline axis?

The block axis runs in the direction that blocks stack - in a standard horizontal document this is top to bottom. The inline axis runs in the direction that text flows - left to right in LTR languages, right to left in RTL languages. In a vertical writing mode like writing-mode: vertical-rl, the two axes swap: the block axis runs left to right and the inline axis runs top to bottom. Logical properties like margin-block-start and margin-inline-end always refer to these relative axes, so they remain semantically correct regardless of writing mode.

What is the logical equivalent of width and height?

width maps to inline-size and height maps to block-size. In a standard horizontal writing mode these are identical in effect, but in a vertical writing mode the axes swap - so inline-size would control what was previously the vertical dimension. This is why the converter flags width and height conversions as worth reviewing: if you are deliberately sizing an element relative to the physical screen (a fixed overlay, a full-height sidebar, an image), keeping the physical property is usually the right choice.

What is the logical equivalent of top, right, bottom, and left for positioning?

The four physical inset properties map to their logical counterparts as follows: topinset-block-start, bottominset-block-end, leftinset-inline-start, rightinset-inline-end. You can also use the inset shorthand, which accepts the same one-to-four value syntax as margin but applies to all four inset sides at once.

Should I use text-align: start/end instead of left/right?

It depends on intent. Use text-align: start and text-align: end when you want text to align with the natural start or end of the inline direction - this is the right choice for most body text and UI labels that should mirror automatically in RTL layouts. Keep text-align: left or text-align: right only when text must be pinned to a specific physical edge regardless of locale - for example, a column of numbers that must always appear on the right side of the screen.

What browsers support CSS logical properties?

All major logical properties for margin, padding, border, sizing, and positioning have been supported in Chrome, Firefox, Safari, and Edge since 2019–2021. Newer additions such as overflow-inline, overflow-block, and the logical border-radius variants (border-start-start-radius etc.) are supported in all current browser versions. For older browser support, declare the physical property first as a fallback and the logical property second - browsers that do not understand logical properties will ignore the second declaration gracefully.

Why do some conversions get flagged for review?

Certain properties have logical equivalents that behave differently depending on writing mode, so a blind conversion could change layout behaviour in ways you may not intend. The converter highlights these in amber to draw your attention. The main cases are: width and height (axes swap in vertical writing modes), text-align: left/right (may need to stay physical for design reasons), float and clear with left/right values, and four-value margin or padding shorthands where the value order changes in the expanded logical form.

Do I need to convert all physical properties, or can I mix them?

You can mix physical and logical properties in the same stylesheet - there is no requirement to convert everything at once. A common approach is to convert spacing and sizing properties (margin, padding, width, height) to logical equivalents first, since these provide the most benefit for internationalisation, and leave positioning or float properties physical until you are confident in the behaviour across writing modes. The per-line revert control in this tool is designed exactly for this incremental workflow.

What is the logical equivalent of border-radius corners?

Each physical corner maps to a logical equivalent using start/end naming: border-top-left-radiusborder-start-start-radius, border-top-right-radiusborder-start-end-radius, border-bottom-left-radiusborder-end-start-radius, border-bottom-right-radiusborder-end-end-radius. The naming convention follows block axis first (start/end) then inline axis (start/end), so border-start-end-radius means the corner at the block-start edge and the inline-end edge.

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong!