Logical borders and insets
Definition and purpose
Logical border and inset properties follow the same axes as logical padding. A decorative leading border or an anchored badge can move automatically when the direction changes.
Leading message border
<!doctype html><html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>CSS practice</title> <style> body { margin: 0; } #a, #b { background: lightblue; } #p { direction: rtl; } #a { border-inline-start: 4px solid navy; } </style> </head> <body> <div id="p"> <div id="a">A</div> <div id="b">B</div> </div> </body></html>The leading border appears on the right.
Syntax and mental model
border-inline-start: 4px solid navy sets the leading edge. On an absolutely positioned child, inset-inline-end: 8px and inset-block-start: 6px place it near the logical end and start edges of its containing block. A positioned ancestor establishes the containing block in these examples.
Badge at logical end
<!doctype html><html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>CSS practice</title> <style> body { margin: 0; } #a, #b { background: lightblue; } #p { direction: rtl; position: relative; width: 200px; height: 80px; } #a { position: absolute; inset-inline-end: 8px; inset-block-start: 6px; width: 30px; height: 20px; } </style> </head> <body> <div id="p"> <div id="a">A</div> <div id="b">B</div> </div> </body></html>In RTL, inline-end is the left side of this box.
Common mistakes
Logical inset is not a margin and does not itself make a static element positioned. Keep badges from overlapping important text by reserving room.
Practice and next steps
After trying the examples, complete the linked coding exercise and review questions. Predict the result before running your code. Prerequisite: Logical sizes and spacing. Next lesson: Bidirectional text and Persian UI.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Logical borders and insets — knowledge check
Five questions on logical borders and insets.
What is border-inline-start in horizontal LTR?
What is inline-end in horizontal RTL?
Does inset alone position a static element?
Which property sets a logical leading border?
What can establish a containing block for the badge?