Skip to content

useLogicalProperties (CSS)

Language CSS
biome.json
{
"linter": {
"rules": {
"nursery": {
"useLogicalProperties": "error"
}
}
}
}

Prefer logical CSS properties over physical properties.

Physical properties such as left, margin-left, and width describe fixed directions or dimensions. Logical properties such as inset-inline-start, margin-inline-start, and inline-size adapt when text runs right to left or uses a vertical writing mode.

p {
margin: 1px 2px;
}
code-block.css:2:3 lint/nursery/useLogicalProperties  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

⚠ Use logical CSS longhands instead of a multi-value physical shorthand.

1 β”‚ p {
> 2 β”‚ margin: 1px 2px;
β”‚ ^^^^^^
3 β”‚ }
4 β”‚

β„Ή Logical properties adapt better to different writing modes and layout directions.

β„Ή Multi-value shorthands always map to physical sides.

β„Ή This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.

β„Ή Unsafe fix: Replace with margin-block and margin-inline.

2 β”‚ Β·Β·margin-block:Β·1px;Β·margin-inline:Β·2px;
β”‚ ++++++ ++++++++++++++++
p {
padding: var(--spacing) 2px;
}
code-block.css:2:3 lint/nursery/useLogicalProperties ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

⚠ Use logical CSS longhands instead of a multi-value physical shorthand.

1 β”‚ p {
> 2 β”‚ padding: var(--spacing) 2px;
β”‚ ^^^^^^^
3 β”‚ }
4 β”‚

β„Ή Logical properties adapt better to different writing modes and layout directions.

β„Ή The variable or function may supply multiple values, so check its substitution and split the shorthand manually.

β„Ή This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.

p {
margin-block-start: 1px;
margin-block-end: 2px;
}
code-block.css:2:3 lint/nursery/useLogicalProperties  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

⚠ These logical longhands can be combined into a shorthand.

1 β”‚ p {
> 2 β”‚ margin-block-start: 1px;
β”‚ ^^^^^^^^^^^^^^^^^^
3 β”‚ margin-block-end: 2px;
4 β”‚ }

β„Ή Logical properties adapt better to different writing modes and layout directions.

β„Ή This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.

β„Ή Unsafe fix: Combine these properties as margin-block.

1 1 β”‚ p {
2 β”‚ - Β·Β·margin-block-start:Β·1px;
3 β”‚ - Β·Β·margin-block-end:Β·2px;
2 β”‚ + Β·Β·margin-block:Β·1pxΒ·2px;
4 3 β”‚ }
5 4 β”‚

p {
width: 100%;
}
code-block.css:2:3 lint/nursery/useLogicalProperties  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

⚠ Use logical CSS properties over physical ones.

1 β”‚ p {
> 2 β”‚ width: 100%;
β”‚ ^^^^^
3 β”‚ }
4 β”‚

β„Ή Logical properties adapt better to different writing modes and layout directions.

β„Ή Replace width with inline-size.

β„Ή This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.

β„Ή Unsafe fix: Use the logical CSS replacement.

1 1 β”‚ p {
2 β”‚ - Β·Β·width:Β·100%;
2 β”‚ + Β·Β·inline-size:Β·100%;
3 3 β”‚ }
4 4 β”‚

p {
top: 0;
}
code-block.css:2:3 lint/nursery/useLogicalProperties  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

⚠ Use logical CSS properties over physical ones.

1 β”‚ p {
> 2 β”‚ top: 0;
β”‚ ^^^
3 β”‚ }
4 β”‚

β„Ή Logical properties adapt better to different writing modes and layout directions.

β„Ή Replace top with inset-block-start.

β„Ή This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.

β„Ή Unsafe fix: Use the logical CSS replacement.

1 1 β”‚ p {
2 β”‚ - Β·Β·top:Β·0;
2 β”‚ + Β·Β·inset-block-start:Β·0;
3 3 β”‚ }
4 4 β”‚

p {
margin-left: 1rem;
}
code-block.css:2:3 lint/nursery/useLogicalProperties  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

⚠ Use logical CSS properties over physical ones.

1 β”‚ p {
> 2 β”‚ margin-left: 1rem;
β”‚ ^^^^^^^^^^^
3 β”‚ }
4 β”‚

β„Ή Logical properties adapt better to different writing modes and layout directions.

β„Ή Replace margin-left with margin-inline-start.

β„Ή This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.

β„Ή Unsafe fix: Use the logical CSS replacement.

1 1 β”‚ p {
2 β”‚ - Β·Β·margin-left:Β·1rem;
2 β”‚ + Β·Β·margin-inline-start:Β·1rem;
3 3 β”‚ }
4 4 β”‚

p {
border-left: 1px solid;
}
code-block.css:2:3 lint/nursery/useLogicalProperties  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

⚠ Use logical CSS properties over physical ones.

1 β”‚ p {
> 2 β”‚ border-left: 1px solid;
β”‚ ^^^^^^^^^^^
3 β”‚ }
4 β”‚

β„Ή Logical properties adapt better to different writing modes and layout directions.

β„Ή Replace border-left with border-inline-start.

β„Ή This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.

β„Ή Unsafe fix: Use the logical CSS replacement.

1 1 β”‚ p {
2 β”‚ - Β·Β·border-left:Β·1pxΒ·solid;
2 β”‚ + Β·Β·border-inline-start:Β·1pxΒ·solid;
3 3 β”‚ }
4 4 β”‚

p {
float: left;
}
code-block.css:2:10 lint/nursery/useLogicalProperties  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

⚠ Use logical CSS values over physical ones.

1 β”‚ p {
> 2 β”‚ float: left;
β”‚ ^^^^
3 β”‚ }
4 β”‚

β„Ή Logical properties adapt better to different writing modes and layout directions.

β„Ή Replace left with inline-start.

β„Ή This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.

β„Ή Unsafe fix: Use the logical CSS replacement.

1 1 β”‚ p {
2 β”‚ - Β·Β·float:Β·left;
2 β”‚ + Β·Β·float:Β·inline-start;
3 3 β”‚ }
4 4 β”‚

p {
text-align: right;
}
code-block.css:2:15 lint/nursery/useLogicalProperties  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

⚠ Use logical CSS values over physical ones.

1 β”‚ p {
> 2 β”‚ text-align: right;
β”‚ ^^^^^
3 β”‚ }
4 β”‚

β„Ή Logical properties adapt better to different writing modes and layout directions.

β„Ή Replace right with end.

β„Ή This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.

β„Ή Unsafe fix: Use the logical CSS replacement.

1 1 β”‚ p {
2 β”‚ - Β·Β·text-align:Β·right;
2 β”‚ + Β·Β·text-align:Β·end;
3 3 β”‚ }
4 4 β”‚

p {
justify-content: left;
}
code-block.css:2:20 lint/nursery/useLogicalProperties ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

⚠ Use logical CSS values over physical ones.

1 β”‚ p {
> 2 β”‚ justify-content: left;
β”‚ ^^^^
3 β”‚ }
4 β”‚

β„Ή Logical properties adapt better to different writing modes and layout directions.

β„Ή Choose a logical alignment value based on the layout axis.

β„Ή This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.

p {
inline-size: anchor-size(width);
}
code-block.css:2:28 lint/nursery/useLogicalProperties  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

⚠ Use a logical size in anchor-size().

1 β”‚ p {
> 2 β”‚ inline-size: anchor-size(width);
β”‚ ^^^^^
3 β”‚ }
4 β”‚

β„Ή Logical properties adapt better to different writing modes and layout directions.

β„Ή Replace width with self-inline.

β„Ή This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.

β„Ή Unsafe fix: Use the logical CSS replacement.

1 1 β”‚ p {
2 β”‚ - Β·Β·inline-size:Β·anchor-size(width);
2 β”‚ + Β·Β·inline-size:Β·anchor-size(self-inline);
3 3 β”‚ }
4 4 β”‚

p {
inset-block-start: anchor(bottom);
}
code-block.css:2:29 lint/nursery/useLogicalProperties  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

⚠ Use a logical side in anchor().

1 β”‚ p {
> 2 β”‚ inset-block-start: anchor(bottom);
β”‚ ^^^^^^
3 β”‚ }
4 β”‚

β„Ή Logical properties adapt better to different writing modes and layout directions.

β„Ή Replace bottom with end.

β„Ή This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.

β„Ή Unsafe fix: Use the logical CSS replacement.

1 1 β”‚ p {
2 β”‚ - Β·Β·inset-block-start:Β·anchor(bottom);
2 β”‚ + Β·Β·inset-block-start:Β·anchor(end);
3 3 β”‚ }
4 4 β”‚

p {
inline-size: 100%;
inset-block-start: 0;
margin-inline-start: 1rem;
border-inline-start: 1px solid;
float: inline-start;
text-align: end;
justify-content: start;
inline-size: anchor-size(self-inline);
block-size: anchor-size(self-block);
inset-block-start: anchor(end);
}

A multi-value physical shorthand always applies values to physical sides. Use separate logical properties when values differ by axis. A four-sided shorthand is only equivalent when all four values are identical, so the rule does not combine differing axis values into one. Shorthands containing var(), env(), attr(), if(), or a SCSS variable are reported without an automatic fix because these values can expand to multiple values. Check the substitution before splitting the shorthand manually.

p {
margin: 1px;
margin: var(--spacing);
margin-block: 1px 2px;
color: red;
}
$spacing: 1rem;
p {
margin: $spacing 2px;
}
code-block.scss:4:3 lint/nursery/useLogicalProperties ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

⚠ Use logical CSS longhands instead of a multi-value physical shorthand.

3 β”‚ p {
> 4 β”‚ margin: $spacing 2px;
β”‚ ^^^^^^
5 β”‚ }
6 β”‚

β„Ή Logical properties adapt better to different writing modes and layout directions.

β„Ή The variable or function may supply multiple values, so check its substitution and split the shorthand manually.

β„Ή This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.

Sets the text direction used to replace left and right properties and to order the inline values when splitting a four-value physical shorthand. Use "ltr" for left-to-right text or "rtl" for right-to-left text. Defaults to "ltr".

biome.json
{
"linter": {
"rules": {
"nursery": {
"useLogicalProperties": {
"level": "on",
"options": {
"direction": "rtl"
}
}
}
}
}
}
p {
margin-left: 1rem;
}
code-block.css:2:3 lint/nursery/useLogicalProperties  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

⚠ Use logical CSS properties over physical ones.

1 β”‚ p {
> 2 β”‚ margin-left: 1rem;
β”‚ ^^^^^^^^^^^
3 β”‚ }
4 β”‚

β„Ή Logical properties adapt better to different writing modes and layout directions.

β„Ή Replace margin-left with margin-inline-end.

β„Ή This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.

β„Ή Unsafe fix: Use the logical CSS replacement.

1 1 β”‚ p {
2 β”‚ - Β·Β·margin-left:Β·1rem;
2 β”‚ + Β·Β·margin-inline-end:Β·1rem;
3 3 β”‚ }
4 4 β”‚

p {
margin: 1px 2px 3px 4px;
}
code-block.css:2:3 lint/nursery/useLogicalProperties  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

⚠ Use logical CSS longhands instead of a multi-value physical shorthand.

1 β”‚ p {
> 2 β”‚ margin: 1px 2px 3px 4px;
β”‚ ^^^^^^
3 β”‚ }
4 β”‚

β„Ή Logical properties adapt better to different writing modes and layout directions.

β„Ή Multi-value shorthands always map to physical sides.

β„Ή This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.

β„Ή Unsafe fix: Replace with margin-block and margin-inline.

1 1 β”‚ p {
2 β”‚ - Β·Β·margin:Β·1pxΒ·2pxΒ·3pxΒ·4px;
2 β”‚ + Β·Β·margin-block:Β·1pxΒ·3px;Β·margin-inline:Β·2pxΒ·4px;
3 3 β”‚ }
4 4 β”‚

p {
margin-inline-end: 1rem;
}