Our store at RAMO sells hardware, plumbing and garden supplies, and most of our customers read Hebrew. That means the whole storefront runs right-to-left. Setting dir="rtl" on the root element is the easy part. It flips the page, and for a day you think you're done.
Then the small bugs show up. None of them are hard, but nobody lists them in one place, so here's ours.
1. Stop writing left and right in CSS
The first round of bugs was always the same: a margin on the wrong side, an icon hugging the wrong edge, a dropdown opening off-screen. Every one came from margin-left , padding-right , left: 0 and friends.
The fix is to use logical properties everywhere:
/* before */ .price-tag { margin-left : 8px ; text-align : left ; }
/* after */ .price-tag { margin-inline-start : 8px ; text-align : start ; }
Enter fullscreen mode
Exit fullscreen mode
inline-start means "the side where text begins", so it follows the direction automatically.โฆ