THE GITHTML FIELD GUIDE

Use logical spacing for mirrored bilingual layouts

Use logical margin and padding properties when spacing should follow the reading direction rather than a physical left or right edge. Keep language and direction declarations accurate, and review mixed-direction examples individually. Logical properties reduce duplicated layout rules but do not translate text or determine the correct order of every component.

Choose the right representation

A left border used to mark the beginning of a note becomes misleading when the note is read right to left. The same issue appears in indentation and label spacing. Logical properties express start and end relationships instead of assuming one physical direction.

Apply the pattern deliberately

Replace direction-sensitive spacing one component at a time. Keep genuinely physical positioning, such as an annotation tied to a screenshot coordinate, explicit. Mixing logical and physical declarations on the same edge can produce confusing overrides that are difficult to maintain.

  1. Identify whether each spacing rule follows reading direction or a fixed physical location.
  2. Use inline-start and inline-end properties for directional indentation and separation.
  3. Inspect mixed-direction labels rather than assuming a mirrored layout proves correct reading order.
css
.note { border-inline-start: 3px solid currentColor; padding-inline-start: 1rem; }

Decide what should mirror and what should not

A note's leading border should usually follow the start of its reading direction. A marker pointing to the left edge of a screenshot may need to stay physically left, because the screenshot itself has not been mirrored. List these cases before replacing every left or right declaration. Logical properties express a layout relationship; they are not a global command to flip all artwork, charts, controls, and examples.

Set language and direction deliberately in the document. Language metadata identifies the language, while direction establishes the base direction for the relevant content. Do not assume that translating words alone updates the layout. When a component behaves unexpectedly, inspect inherited direction, its writing mode, and any later physical margin or padding rule that competes with the logical declaration. Change one component at a time so the reason for each mirrored edge remains clear.

Review a mixed example containing prose, a version number, and a repository identifier. The surrounding paragraph may read right to left while the identifier needs its own predictable ordering. Ask a reader familiar with the language to check punctuation and associations, not merely whether the border moved. Verify both language versions after a shared stylesheet change. A bilingual document is successful when each reader can follow the information correctly; visual symmetry by itself is not enough.

Check the finished reading experience

Review the component with both left-to-right and right-to-left passages. Check numbers and embedded identifiers separately because their internal order may differ from the surrounding prose.

Sources and further reading

AI-assisted writing with source-linked guidance and illustrative examples. Read our editorial approach or report a correction.

All reading html on your phone guides →

Read as MarkdownAll guides

Use logical spacing for mirrored bilingual layouts · gitHtml