Why it matters
- Lines on an Arabic page start at the right.
margin-leftstays on the left in either direction, whilemargin-inline-startis on the right of an Arabic page and on the left of an English one. - Many themes are written for English pages, so when the page becomes Arabic, spacing, alignment and floated elements stay on their old side. A common case:
ul { padding-left: 0 }does not remove a list's indent on an Arabic page, because the browser puts it at the start of the line, on the right. - Logical properties let one stylesheet serve both directions, instead of a second one for Arabic that goes out of date.
- This rule is for information only and never lowers the score: physical properties are fine when written for this direction on purpose.
Example
ul.menu { padding-left: 0; list-style: none; } .menu li { float: left; margin-right: 16px; }
ul.menu { padding-inline-start: 0; list-style: none; } .menu li { float: inline-start; margin-inline-end: 16px; }
How to fix
Use logical properties, which follow the page's direction:
| Instead of | Use |
|---|---|
margin-left and margin-right | margin-inline-start and margin-inline-end |
padding-left and padding-right | padding-inline-start and padding-inline-end |
border-left and border-right | border-inline-start and border-inline-end |
left and right | inset-inline-start and inset-inline-end |
text-align: left | text-align: start |
float: left | float: inline-start |
- In Tailwind CSS, use the logical classes:
ms-4andme-4instead ofml-4andmr-4,ps-4andpe-4instead ofpl-4andpr-4,start-0andend-0instead ofleft-0andright-0, andtext-startinstead oftext-left. - With Bootstrap, use
bootstrap.rtl.min.csson Arabic pages. - When a site has a stylesheet of its own for Arabic, such as one RTLCSS generates, the physical properties in it are meant. Files with
rtlin their name are not counted.
How we detect
- We render the page and read the stylesheets the browser loaded, and its
<style>elements. - In each, we count the declarations that set a side by left or right:
margin-left,padding-right,border-left,left,rightand the corners ofborder-radius, and the valuesleftandrightoffloat,clearandtext-align. - We leave out rules written for one direction or language, such as
[dir="rtl"],:dir(rtl),.rtland:lang(ar); blocks that set their owndirection; opposite properties set to the same value (left: 0; right: 0); animations in@keyframes; and files withrtlin their name. - We report each stylesheet once, with its count and its first declaration. The page's
<style>elements count as one. - We do not read a file whose size we could not know before reading it, or one larger than the limit.