Picture this: you've built a beautiful card component. The padding looks perfect in English. Then you're asked to add Arabic support, and suddenly everything is back to front: your left-aligned icon is on the wrong side, your margin-left pushes content the wrong way, and you're drowning in [dir="rtl"] overrides that double the size of your stylesheet.
Or imagine adding vertical Japanese text. Your width and height now point in the wrong directions relative to the text, and your carefully tuned padding no longer lines up with how the text flows. You add more workarounds. The code grows, and your confidence shrinks.
CSS logical properties were designed to solve exactly these problems. Rather than tying spacing and sizing to fixed physical directions (top, bottom, left and right), they tie them to the flow of the content. The browser works out which physical side that means, based on the writing-mode and direction of the text. Your CSS stays lean, and every language just works.
The core idea: logical properties describe positions relative to how content flows, not where it appears on screen. In English, which reads left to right (LTR), inline-start means left. In Arabic, which reads right to left (RTL), it means right. In vertical Japanese text, it means the top. The same CSS handles all three.
Logical properties aren't experimental: they've worked in all major browsers for years. The challenge is building the mental model, so they feel as natural as margin-top.
The two axes
The whole system rests on two axes. Margin, padding, borders, sizing and positioning are all described in terms of these two axes, rather than physical directions.
The block axis
The block axis is the direction in which blocks of content, such as paragraphs, stack up. In English, new paragraphs appear below the previous ones, so the block axis runs top to bottom: block-start is the top, and block-end is the bottom.
A handy way to remember it: block is the direction the page grows as you add more content. On a normal web page, it's also the direction you scroll.
The inline axis
The inline axis is the direction text runs along a line. In English, that's left to right: inline-start is the left edge where a line begins, and inline-end is the right edge where it ends. In Arabic, these swap: inline-start is on the right.
Think of it as: inline is the direction a sentence flows. Letters in a word, and words in a sentence, sit along the inline axis.
Neither axis is fixed to a physical direction. They flip and rotate with the direction and writing-mode of the content, and logical properties go with them automatically. You write the CSS once, and the browser handles the geometry.
Choose a property below to see which edge of the box it affects, in English text:
Shorthands as a bonus
The logical shorthands are handy in their own right. padding-block: 1rem 2rem sets the block-start padding to 1rem and the block-end padding to 2rem in one declaration, where the physical version needed padding-top and padding-bottom. And margin-inline: auto says "centre this along the line" more clearly than setting both margin-left and margin-right.
Physical vs logical: full reference
The names follow a consistent pattern: property, then axis, then side. Pick a property (margin, padding, border or inset), add an axis (block or inline), then optionally a side (start or end). Leave the side off to set both sides of that axis at once. Once you know the pattern, you can work out any logical property name without memorising a list. For details of every property, see our CSS properties reference.
The tables below show the equivalents for English and other horizontal, left-to-right text.
Margin and padding
| Physical | Logical | Shorthand for both sides |
|---|---|---|
margin-top | margin-block-start | margin-block |
margin-bottom | margin-block-end | |
margin-left | margin-inline-start | margin-inline |
margin-right | margin-inline-end | |
padding-top | padding-block-start | padding-block |
padding-bottom | padding-block-end | |
padding-left | padding-inline-start | padding-inline |
padding-right | padding-inline-end |
Borders
Borders follow the same pattern. border-block and border-inline style both edges of an axis at once, something that took two declarations with physical properties.
| Physical | Logical | Shorthand for both sides |
|---|---|---|
border-top | border-block-start | border-block |
border-bottom | border-block-end | |
border-left | border-inline-start | border-inline |
border-right | border-inline-end | |
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 | - |
Border-radius naming: the double names, such as border-start-start-radius, trip people up at first. Read them as "the corner where block-start meets inline-start": the block side comes first, then the inline side. In English that's the top-left corner; in Arabic, it's the top-right.
Sizing
width and height are always physical: width is horizontal, whatever the language. inline-size is the size along the line of text, and block-size is the size in the direction blocks stack. In horizontal writing, inline-size is the same as width; in vertical writing, it's the same as height.
| Physical | Logical |
|---|---|
width | inline-size |
height | block-size |
min-width / max-width | min-inline-size / max-inline-size |
min-height / max-height | min-block-size / max-block-size |
Positioning
The inset properties replace top, right, bottom and left for positioned elements. The plain inset shorthand sets all four physical sides at once (it isn't logical itself, but it arrived alongside the logical properties).
| Physical | Logical | Shorthand for both sides |
|---|---|---|
top | inset-block-start | inset-block |
bottom | inset-block-end | |
left | inset-inline-start | inset-inline |
right | inset-inline-end | |
top, right, bottom and left together | - | inset (physical) |
The RTL problem, solved
Supporting right-to-left languages has traditionally been one of the most painful parts of preparing a site for other languages. The usual approach was to write all your CSS for left-to-right first, then add a large [dir="rtl"] block that mirrors every physical property. That block doubles your spacing CSS, easily falls out of step with changes to the main styles, and often goes untested by developers who don't read RTL languages.
The real problem is that you're writing two sets of rules for one idea: "this element should have space on the side where reading starts". Logical properties let you say that once.
The old approach
/* Left-to-right styles */
.nav-icon {
float: left;
margin-right: 0.75rem;
padding-left: 1rem;
border-left: 2px solid var(--brand);
}
/* Right-to-left overrides: written separately, easy to forget */
[dir="rtl"] .nav-icon {
float: right;
margin-right: 0;
margin-left: 0.75rem;
padding-left: 0;
padding-right: 1rem;
border-left: none;
border-right: 2px solid var(--brand);
}
The logical approach
/* One rule. Works for both directions. */
.nav-icon {
float: inline-start; /* float accepts logical values too */
margin-inline-end: 0.75rem; /* space after the icon, in reading order */
padding-inline-start: 1rem; /* space on the side where reading starts */
border-inline-start: 2px solid var(--brand);
}
Switch the direction below to compare a box built with physical properties against one built with logical properties:
Physical: margin-left, padding-left, border-left
Logical: margin-inline-start, padding-inline, border-inline-start
RTL is now active. The red box (physical properties) still has its border and indent on the left, the wrong side for right-to-left text. The blue box (logical properties) has mirrored correctly, with no extra CSS.
text-align and float have logical values too
It's not just spacing. text-align accepts start and end, so text lines up with the correct edge in both directions. float accepts inline-start and inline-end. And resize: block or resize: inline limits a <textarea> to resizing along one axis.
p { text-align: start; } /* left in LTR, right in RTL */
.label { text-align: end; } /* right in LTR, left in RTL */
.hero { text-align: center; } /* centre works in every direction already */
.pull-quote { float: inline-end; } /* right in LTR, left in RTL */
Tip: to switch a page to right-to-left, set the dir="rtl" attribute in your HTML, usually on the <html> element, along with the right lang. Avoid setting direction in CSS for this: text direction is part of the content's meaning, so it belongs in the HTML.
Writing modes and vertical text
Logical properties are just as useful for vertical writing. Japanese, Chinese and Korean text is often laid out with writing-mode: vertical-rl: text runs from top to bottom, and each new column appears to the left of the previous one. This is common in traditional literature, newspapers and many Japanese designs. Traditional Mongolian script uses writing-mode: vertical-lr, where new columns appear to the right instead.
In vertical writing, the axes rotate. The block axis now runs horizontally, because that's the direction new columns stack, and the inline axis runs vertically, because that's the direction text flows. With physical properties, you'd have to rethink every bit of spacing. With logical properties, padding-inline automatically adds space above and below the text, exactly as it should.
Choose a writing mode to see where each logical side ends up:
A vertical text example
Say you're building a Japanese article with a side label in writing-mode: vertical-rl. With physical properties, you might use padding-left and padding-right for breathing room. But in vertical writing, left and right are along the block axis, so that padding lands across the columns, not along the text. padding-inline always adds space along the text, whichever physical direction that is:
.sidebar-label {
writing-mode: vertical-rl;
/* Physical: adds space across the columns, not along the text */
padding-left: 1rem;
padding-right: 1rem;
/* Logical: always along the text */
padding-inline: 1rem; /* top and bottom, in vertical-rl */
padding-block: 0.5rem; /* right and left, in vertical-rl */
}
Logical properties in practice
A live playground
Move the sliders to adjust the box's padding, border and margin along each logical axis. The CSS below updates as you go, using the shorthand when both sides of an axis match:
A real card component
Here's a notification card, the kind you'd find in a design system, written entirely with logical properties. It works in left-to-right, right-to-left and vertical writing with no extra CSS:
.notification-card {
position: relative;
inline-size: 100%;
max-inline-size: 420px;
padding-block: 1.25rem;
padding-inline: 1.5rem;
/* Accent border on the side where reading starts */
border-inline-start: 4px solid var(--brand);
/* Round only the corners on the other side */
border-start-end-radius: 8px;
border-end-end-radius: 8px;
}
.notification-card__icon {
margin-inline-end: 0.75rem; /* space after the icon, in reading order */
}
.notification-card__badge {
position: absolute;
inset-block-start: 0.75rem; /* top */
inset-inline-end: 0.75rem; /* right in LTR, left in RTL */
}
.notification-card__timestamp {
display: block;
margin-block-start: 0.5rem; /* space above the timestamp */
text-align: end; /* aligned with the edge where reading ends */
}
The centring pattern to retire
The easiest win in any codebase: replace margin-left: auto; margin-right: auto; with margin-inline: auto. It's shorter, works in every writing mode, and says exactly what it means: share the spare space equally on both sides of the line.
/* Old: two physical properties */
.centred {
margin-left: auto;
margin-right: auto;
}
/* New: one logical property */
.centred {
margin-inline: auto;
}
Migrating an existing codebase
You don't need to rewrite your whole stylesheet at once. The best approach is gradual: use logical properties for all new code, convert existing code as you work on it, and use tools to keep everyone consistent.
Step 1: start with matching pairs
The safest place to start is any pair of properties set to the same value on both sides, such as equal left and right padding. These conversions look identical in left-to-right layouts. If you'd rather not convert by hand, our CSS logical properties converter can translate physical properties to their logical equivalents for you.
margin-left: auto;
margin-right: auto;margin-inline: auto;padding-top: 1rem;
padding-bottom: 1rem;padding-block: 1rem;padding-left: 1.5rem;
padding-right: 1.5rem;padding-inline: 1.5rem;width: 100%;
max-width: 800px;inline-size: 100%;
max-inline-size: 800px;text-align: left;text-align: start;Step 2: think about intent
Not every physical property should become a logical one. Before converting, ask: should this flip in a right-to-left or vertical layout? A "back to top" button that should always sit in the bottom-right corner, whatever the language, should keep right: 1rem; bottom: 1rem. Use physical properties for fixed design decisions, and logical properties for anything that follows the content.
Don't convert everything blindly: if a notification panel should always appear on the right of the screen, keep right: 0. Changing it to inset-inline-end: 0 would move it to the left in right-to-left languages, which isn't what the design intended.
Step 3: update your design tokens
If you use CSS custom properties or design tokens, check their names. A token called --spacing-left-sm builds a physical direction into its name. Better still, keep tokens about sizes only, such as --spacing-sm, and decide which side they apply to in each component, with logical properties.
Browser support
Logical properties work in all modern browsers, with no flags or prefixes:
| Feature | Support |
|---|---|
| Logical margin, padding, border, inset and sizing properties | All major browsers since 2021 |
| Logical border-radius properties | All major browsers since 2021 |
text-align: start and end | All major browsers, for many years |
float: inline-start and inline-end | All major browsers since late 2023 |
If you need to support older browsers, put a physical fallback before the logical declaration. Browsers that don't understand the logical property ignore it and use the fallback; browsers that do understand it use the later, logical value:
.element {
margin-left: 1.5rem; /* fallback for older browsers */
margin-inline-start: 1.5rem; /* used by modern browsers */
}
When should you use them?
For new CSS, logical properties make a good default. They're well supported, the shorthands are shorter and clearer, and your layouts are ready for other languages from the start.
Use logical properties for
- spacing that should flip in right-to-left layouts (margin, padding and borders)
- sizes that should adapt to vertical writing (
inline-sizeandblock-size) - new components in a design system
- positioning things relative to the text, such as icons, badges and timestamps
- centring with
margin-inline: auto - text alignment that should follow the reading direction
Keep physical properties for
- elements deliberately fixed to one side of the screen, whatever the language
- coordinates in canvas, SVG or WebGL drawings, where logical properties don't apply
- deliberate design choices that shouldn't mirror
Quick decision rule: ask "should this spacing or position flip if the page were in Arabic or vertical Japanese?" If the answer is yes, or you're not sure, use a logical property. Save physical properties for deliberate, fixed design decisions.
TL;DR
CSS logical properties replace physical directions (top, left and so on) with flow-relative ones (block-start, inline-start and so on) that adapt automatically to the direction and writing mode of the text. They remove the need for right-to-left override blocks, make vertical layouts work by default, and produce shorter, clearer CSS. They work in all modern browsers, you can adopt them gradually, and tools such as Tailwind (with its ms-, me-, ps- and pe- utilities) and Stylelint plugins support them.
The next time you reach for padding-left, pause and ask whether padding-inline-start better describes what you mean. Nine times out of ten, it will.