Codectionary / Developer documentation / CSS

Logical Properties

Logical properties describe direction in terms of writing mode (inline/block flow) rather than fixed physical directions (left/right/top/bottom). margin-inline-start behaves like margin-left in English but automatically adapts for right-to-left languages, making them essential for properly internationalized layouts.

Syntax

margin-inline-start, padding-block, inset-inline-end

Examples

Physical vs Logical Properties

The same intent, expressed in a way that adapts to writing direction.

/* Physical - assumes left-to-right, breaks in RTL languages */
.old {
  margin-left: 16px;
  border-right: 1px solid gray;
}

/* Logical - automatically flips for RTL languages like Arabic or Hebrew */
.modern {
  margin-inline-start: 16px;
  border-inline-end: 1px solid gray;
}

Block and Inline Direction

Common shorthand logical properties for spacing.

.card {
  padding-block: 16px;   /* top and bottom, in the block direction */
  padding-inline: 24px;  /* left and right, in the inline direction */
}

Parameters and values

  • margin-inline-start/end (length): Logical equivalent of margin-left/right in LTR
  • padding-block (length): Shorthand for padding-top and padding-bottom
  • inset-inline / inset-block (length): Logical equivalents of left/right and top/bottom for positioning

Best practices

  • Use logical properties by default in new projects, even if you are not currently building a multilingual site - they cost nothing and future-proof the layout
  • This matters most for genuinely internationalized products supporting right-to-left languages like Arabic or Hebrew
  • Logical properties exist for nearly every physical spacing/sizing/positioning property - margin, padding, border, inset, width (inline-size), and height (block-size)
  • Mixing physical and logical properties in the same project is fine during migration, but aim for consistency within a single component

At a glance

Purpose
Presentation and layout
File extension
.css
Runs in
Web browsers
Usually used with
HTML and JavaScript

Specifications & further reading

Related CSS documentation