Sub topic 11
Corner Radius with Logical Corners
This chapter assumes you know the box model, how border-radius works, and how writing-mode and direction set the block and inline axes. Earlier chapters covered logical margin, padding, borders and inset.
The problem with physical corners
border-radius uses physical corners: border-top-left-radius, border-top-right-radius, border-bottom-right-radius and border-bottom-left-radius. This causes trouble when a design is tied to the reading direction.
Take a speech bubble whose "tail" corner should be square. In English the tail is at the bottom left. In Arabic the same bubble should have its tail at the bottom right. A physical radius gives you the wrong corner in one of the two languages.
The four logical corners
Logical corner properties name a corner by two flow-relative sides. The first part is the block side. The second part is the inline side.
| Logical property | Corner in `ltr` + `horizontal-tb` | Corner in `rtl` + `horizontal-tb` |
|---|---|---|
| `border-start-start-radius` | top left | top right |
| `border-start-end-radius` | top right | top left |
| `border-end-start-radius` | bottom left | bottom right |
| `border-end-end-radius` | bottom right | bottom left |
Read each name as "block side, then inline side". So border-start-end-radius is the corner where the block-start edge meets the inline-end edge.
A chat bubble that follows the text
This rule rounds three corners and leaves the end-end corner sharp. The sharp corner is at the bottom right in English and at the bottom left in Arabic.
<p dir="ltr" lang="en" class="bubble">Hello</p>
<p dir="rtl" lang="ar" class="bubble">مرحبا</p>
<style>
.bubble {
padding: 0.75rem 1rem;
background: #dbeafe;
border-radius: 1rem;
border-end-end-radius: 0;
}
</style>The shorthand border-radius: 1rem rounds all four corners. The later logical declaration then overrides one corner. Order matters here. If you put border-end-end-radius first, the shorthand would reset it.
Elliptical corners
Each logical corner property accepts one or two lengths. With two values, the first is the horizontal radius and the second is the vertical radius of the corner's curve.
.tab {
border-start-start-radius: 1rem 0.5rem;
border-start-end-radius: 1rem 0.5rem;
}Those two values remain physical measurements. They are not flipped by writing mode. In a vertical writing mode the first value is still along the horizontal axis of the screen.
No two-value shorthand
Unlike margin, padding and inset, radius has no -inline or -block shorthand. There is no border-inline-radius. To round both start corners, write both longhands.
.tabs-item {
border-start-start-radius: 0.5rem;
border-start-end-radius: 0.5rem;
}The border-radius shorthand itself stays physical, so it is only safe when all values are equal or when the layout never changes direction.
Common errors
- Reading the name as "inline, then block". The order is block first, then inline.
- Putting a logical longhand before the
border-radiusshorthand, which resets it. - Expecting
border-inline-start-radiusto exist. It does not. - Expecting the two-value elliptical radius to rotate with the writing mode.
Exercise
A tab sits above its content. Its top corners should be rounded in both English and Arabic, and its bottom corners should be square. Which two logical properties do you set, and does the result differ between dir="ltr" and dir="rtl"?
Show answer
Set border-start-start-radius and border-start-end-radius to the radius you want, for example 0.5rem, and leave the end corners at 0. Together they cover the whole block-start edge, so the same two rules round the top corners in both directions. Only which one is the left or right corner swaps, and that does not change the visible result.