useLogicalProperties (CSS)
Language CSS
Summary
Section titled “Summary”- Rule available since:
v2.5.15 - Diagnostic Category:
lint/nursery/useLogicalProperties - This rule doesn’t have a fix.
- The default severity of this rule is warning.
How to configure
Section titled “How to configure”{ "linter": { "rules": { "nursery": { "useLogicalProperties": "error" } } }}Description
Section titled “Description”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.
Examples
Section titled “Examples”Invalid
Section titled “Invalid”p { width: 100%;}code-block.css:2:3 lint/nursery/useLogicalProperties ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚠ 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.
p { top: 0;}code-block.css:2:3 lint/nursery/useLogicalProperties ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚠ 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.
p { margin-left: 1rem;}code-block.css:2:3 lint/nursery/useLogicalProperties ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚠ 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.
p { border-left: 1px solid;}code-block.css:2:3 lint/nursery/useLogicalProperties ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚠ 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.
p { inline-size: 100%; inset-block-start: 0; margin-inline-start: 1rem; border-inline-start: 1px solid;}Options
Section titled “Options”direction
Section titled “direction”Sets the text direction used to replace left and right properties. Use "ltr" for
left-to-right text or "rtl" for right-to-left text. Defaults to "ltr".
{ "linter": { "rules": { "nursery": { "useLogicalProperties": { "level": "on", "options": { "direction": "rtl" } } } } }}Invalid
Section titled “Invalid”p { margin-left: 1rem;}code-block.css:2:3 lint/nursery/useLogicalProperties ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚠ 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.
p { margin-inline-end: 1rem;}Related links
Section titled “Related links”Copyright (c) 2023-present Biome Developers and Contributors.