Correct-to-Left Styling 101

Correct-to-Left Styling 101

Attain you like my screech? That it is seemingly you’ll relief and choose me a coffee. Thanks so vital!

Over 292 million members spherical the realm train Arabic as their first language. Arabic (al-Arabiyyah, pronounced /al ʕarabijja/, /ʕarabiː/) is my native language, and I most steadily form web sites that must relief each left-to-lawful (LTR) and lawful-to-left (RTL) styles.

Introduction to RTL styling #

The default web page direction in CSS is LTR. In case you confirm the browser of your decision and witness the browser’s default agent styles for the html aspect, which it is seemingly you’ll witness that ltr is the default price for the dir (or “direction”) property. Below is a fundamental instance to existing the adaptation between an LTR and an RTL layout.

Ogle for the RTL portion, the textual screech reads from lawful to left, which is the replacement of the LTR textual screech. Fortunately, the browser did all of the work for this easy instance. To exchange a story’s language direction, which it is seemingly you’ll must add the dir attribute to the muse aspect.

<html dir="rtl">...html>

When the dir is modified, the next aspects have to flip robotically: headings, paragraphs, links, photos, and produce aspects.

It’s price declaring that there is a dir="auto" attribute, which switches the direction robotically based mostly on the screech parsed. In response to the HTML specification:

Authors are urged to simply use this price as a remaining resort when the direction of the textual screech is truly unknown, and no better server-aspect heuristic could moreover be utilized.

Look the Pen
RTL Styling – Classic Instance
by Ahmad Shadeed (@shadeed)
on CodePen.

In addition to setting the dir=rtl attribute on the HTML aspect, we could moreover add direction: rtl as a CSS fashion.

.aspect { direction:  rtl; }

Nonetheless, the CSSWG recommends that the direction ought to be defined on the html root aspect to make sure the upright bidirectional layout within the absence of CSS.

Classic Instance of Flipping a Catch #

Let’s explore a more detailed instance to explore programs to flip a form from LTR to RTL.


<article class="media">

<img src="blueberry-cheesecake.jpg" alt="">

<div class="media__content">

<h2>Blueberry Cheesecakeh2>


<p><a href="#" class="link">Seek Recipea>p>



First and main, I old fashion the right outmoded float to align the image to the left within the LTR form — and, of course, I old fashion a clearfix.

.media:after {

screech: "";

present: block;

obvious: each;


.media__photo {

float: left;

width: 200px;

margin-lawful: 16px;


After we add dir="rtl" for the Arabic aspect, the cease end result appears like this:

All the pieces is flipped other than for the image. That’s because it has float: left and margin-lawful: 16px. To resolve that, we’ve got to override those styles:

.media[dir="rtl] img {

float: lawful;

margin-lawful: 0;

margin-left: 16px;


Look the Pen
RTL Styling – Instance 1 – Floats
by Ahmad Shadeed (@shadeed)
on CodePen.

Mixing English and Arabic Protest material in an LTR Structure #

What would happen if some textual screech had a combination of English and Arabic words, while the layout used to be LTR? Well, the cease end result would peep queer.

The browser reveals the title improperly. For an Arabic speaker, the title could per chance be confusing to read, unless you’re the creator who wrote it. It goes to read within the affirm proven within the figure beneath.

To connect remote from this jam, predicament the unswerving language direction at any time when which which it is seemingly you’ll mediate of. Once dir="rtl" is decided on the aspect, this could appear as expected.

Look the Pen
RTL Styling – Test
by Ahmad Shadeed (@shadeed)
on CodePen.

It would rep more complex when the title is longer. Below, I’ve made the title rather longer, and the cease end result used to be unexpected. I’ve affixed numbers to existing the upright affirm.

When dir="rtl is decided on the aspect, the title is way clearer. That is, the sentence appears grammatically upright and within the lawful affirm.

Look the Pen
RTL Styling – Test 2
by Ahmad Shadeed (@shadeed)
on CodePen.

Handling Fonts #

In response to the form for every LTR and RTL layouts, there ought to be a particular font for every direction. Some fonts can work for more than one languages, which could per chance be spacious. Nonetheless, manufacturers and companies are inclined to use a decided font for RTL.

To legend for that, we must always elaborate a decided font within the font settings of your project. Look Automation Instruments for more critical components.

Font Family #

In CSS, font-family works in a way that makes it clear-gash to drop support to another font, in case a font did no longer load. Nonetheless, it turned out that if specific glyphs are no longer supported by the principle font within the declaration, this could are trying to use the second font.

In response to MDN:

Font option does no longer simply quit on the principle font within the list that is on the actual person’s machine. Moderately, font option is performed one personality at a time, in philosophize that if an within the market font does no longer have a glyph for a compulsory personality, the latter fonts are tried.

Omar Bourhaouta made the next demo which proves the above idea:

Look the Pen
RTL font fallback
by omar bourhaouta (@bourhaouta)
on CodePen.

body {

font-family: 'Roboto','Amiri', sans-serif;


The Roboto font did no longer recongnize the Arabic glyphs, so it falled support to the second font declaration.

Flexbox Structure Module #

Flexbox depends mostly on the writing mode of the story. The writing mode is old fashion to specify how blocks are laid out on the web page. As an instance, a Chinese language web predicament is laid out from top to bottom. The writing mode is for this motive. In flexbox, objects are dispensed in step with the writing mode of the story. The default price for writing-mode in English and Arabic is horizontal-tb.

In response to Mozilla Developer Community (MDN), horizontal-tb ability the next:

Protest material flows horizontally from left to lawful, vertically from top to bottom. The subsequent horizontal line is positioned beneath the earlier line.

When the web page’s direction is modified to RTL, flexbox will flip its objects accordingly. That’s an mountainous support! The illustration beneath reveals how the flexbox axis is flipped based mostly on the direction.

In the instance beneath, I’ve laid out three objects and numbered every of them to existing the adaptation when the direction adjustments.

<div class="element">

<div class="item">1div>

<div class="item">2div>

<div class="item">3div>

.aspect {

present: flex;

flex-direction: row;


Look the Pen
RTL Styling – Test 3
by Ahmad Shadeed (@shadeed)
on CodePen.

Grid Structure Module #

Indulge in flexbox, the grid layout module depends on the writing mode of the story, which provides us the identical support that we rep from using flexbox.

In the instance beneath, the sidebar ought to be on the left and the famous screech on the lawful when the direction is LTR. For RTL, it’s vice versa. After we use CSS grid, the flipping shall be accomplished robotically in step with the web page’s direction.

<div class="element">

<div class="side">Facetdiv>

<div class="main">Majordiv>

.aspect {

present: grid;

grid-template-columns: 220px 1fr;

grid-gap: 1rem;


Look the Pen
RTL Styling – Test 4
by Ahmad Shadeed (@shadeed)
on CodePen.

Usual Mistakes When Flipping to RTL #

Non-Arabic speakers invent some typical errors that are clear-gash to build.

1. Letter-Spacing #

In English, it’s typical to add letter-spacing to adjust the letters of a note. It’s is also named tracking in typography. Take present of the next instance for English screech. It appears typical.

Nonetheless, if the identical letter-spacing fashion used to be added to Arabic screech, it would peep queer. Take present of the next right-existence instance.

Ogle that within the screech with letter-spacing, every note’s letters peep disconnected from every other. That’s no longer lawful. Arabic letters are supposed to peep connected, and conserving the English letter-spacing works against that. Win certain to predicament letter-spacing: 0 when engaged on a multilingual layout.

Look the Pen
RTL Styling – Test 6
by Ahmad Shadeed (@shadeed)
on CodePen.

2. Text Transparency #

It’s typical to commerce the transparency of textual screech shade — to invent it peep secondary, for example. That works in English. Nonetheless, when the screech is Arabic, it causes a queer textual screech-rendering jam.

There are some areas with a decided shade between letters. On this case, letter-spacing hasn’t been adjusted, so the jam is no longer linked to that. The answer is only to predicament the shade without RGBa or opacity.

Look the Pen
RTL Styling – Test 7
by Ahmad Shadeed (@shadeed)
on CodePen.

3. Variations in Word Sizes Between Languages #

Ceaselessly, when a web predicament is translated into Arabic, the sizing of aspects adjustments attributable to about a words becoming greater or smaller after translation. Take present of the next instance, in which I’ve mocked up the navigation of Smashing Magazine’s web predicament.

In the Arabic model, about a of the words are almost the identical dimension as their English counterparts, some are the identical, and some are greater. To invent it clearer, here’s a comparability of each note and its Arabic translation.

That you simply would be in a position to very properly be wondering why I’m talking about variations in note sizes, since this is typical and expected. Take present of the next right-existence instance from LinkedIn.

The button “Performed” is translated to “تم” in Arabic, which makes the button too slight and appears queer. It can per chance be better to have a min-width for the button to legend for such cases. I’ve added that within the browser’s developer tools to existing how it’s meant to peep:

And here’s a in actuality same instance from Twitter:

Please present that the points above on LinkedIn and Twitter have been spotted by yours in point of fact as of the time of writing (13 December 2019).

4. Text Truncation #

I once labored on a project with blended screech, and I faced a discipline linked to textual screech truncation within the cross direction. Take present of the next instance.

The truncation for the English textual screech is unsuitable. It ought to be on the cease of the aspect, no longer the open of it. To resolve that, predicament the attribute dir="auto" on the aspect itself, and then the browser will robotically parse the screech and deem which dir it is.

<p dir="auto">أهلاً وسهلاً بكم في المقال الذي يتحدث عن تصميم صفحات الويب للغة العربيةp>

<p dir="auto">Welcome to the article that explains programs to form for RTL pages.p>

Look the Pen
RTL Styling – Truncation
by Ahmad Shadeed (@shadeed)
on CodePen.

5. Selecting a Immoral RTL Font #

Having an RTL model of a form doesn’t imply which it is seemingly you’ll capture the machine’s default font and rep in touch with it a day. The font has to be picked in moderation to make sure right readability. An instance of this is Twitter:

From an Arabic speaker’s point of peep, the note “تغريد” is onerous to read for about a causes:

  • The font is no longer right.
  • The plucky weight hinders readability.
  • The note’s dots are slight and in actuality near the letters.

I’ve mocked up a form that appears to be like clearer:

6. Mixing Hindi and Arabic Numerals #

In Arabic, there are two programs of writing numbers:

  • Hindi: ٠ ١ ٢ ٣ ٤ ٥ ٦ ٧ ٨ ٩
  • Arabic: 0 1 2 3 4 5 6 7 8 9

The numbers old fashion in English are inherited from the Arabic ones: “0, 1, 2, 3, 4, 5, 6, 7, 8, 9”. Protest material that has numbers ought to be consistent, both Hindi or Arabic numerals.

In response to Wikipedia:

The reason the digits are more repeatedly is named “Arabic numerals” in Europe and the Americas is that they have been introduced to Europe within the 10th century by Arabic-speakers of North Africa, who have been then using the digits from Libya to Morocco.

The following mockup has a combination of Hindi and Arabic numbers. It appears inconsistent, and it could per chance peep unified with one form of numerals.

Usual Issues That Could well Not Work for RTL #

1. Line High #

It’s typical to predicament a decided typeface for a RTL layout. On this case, take a look at how the screech appears on one and more than one traces. In the next instance, the spacing between traces for the Arabic textual screech is lower than for the English one, even though each of them have the identical line-top.

It’s critical to legend for this and to provide a like minded line-top for the Arabic screech.

Look the Pen
RTL Styling – Test 8
by Ahmad Shadeed (@shadeed)
on CodePen.

On Twitter, for example, there is a button with lower-off screech attributable to an defective price for line-top.

Ogle that within the principle image, an Arabic diacritic is lower off. It’s known as the “kasra”, and it’s famous for discovering out the note accurately. In the adjoining image, I’ve mounted the twin carriageway top, and now it appears to be like in burly without being lower off.

The default textual screech underline appears depraved when old fashion with Arabic words. This relates to how words and letters are written in Arabic. Look the next illustration:

I’ve highlighted the queer areas with a purple circle. The underline is roughly overlaying the dots of the letters. Aloof no longer obvious? Right here is a close-up:

The dots highlighted in blue overlap with the underline. This is no longer right, and it makes the textual screech onerous to read. The answer is to use a custom underline with CSS.

2.1. Text Decoration #

It’s which which it is seemingly you’ll mediate of to commerce the underline’s fashion and shade with the contemporary textual screech-decoration-fashion and textual screech-decoration-shade properties. Nonetheless, it is no longer assured to work with all typefaces and font sizes. At the time of writing, Firefox is the browser that has the one relief for these properties.

Update: 18 Jan 2020

In response to this jam on Github, it turned out that using textual screech-decoration-skip-ink property can resolve the jam of dots overlapping with the underline. The default price for it is skip.

Look the Pen
RTL Styling – Text Decoration
by Ahmad Shadeed (@shadeed)
on CodePen.

At the time of writing, it be no longer supported in Safari, outmoded Edge (The chromium Edge supports it). Right here is how it appears in Safari:

2.2. Field Shadow #

Browser relief for field-shadow is way better than for textual screech-decoration. It’s which which it is seemingly you’ll mediate of to detect relief for one amongst the contemporary textual screech-decoration properties, and if the browser does no longer relief it, then this could drop support to the field-shadow property.

.link-3 {

shade: #000;

textual screech-decoration-shade: rgba(21, 132, 196, 0.2);

textual screech-decoration-fashion: typical;

textual screech-underline-offset: 4px;

textual screech-decoration-thickness: 2px;

field-shadow: inset 0 -5px 0 0 rgba(#1584c4, 0.2);


@supports (textual screech-decoration-shade: purple){

.link-3 {

field-shadow: none;



3. Line Crash #

In case your CSS has the note-ruin property, you’ll must take a look at it because it would ruin Arabic words. Take present of the next:

The circled areas are broken Arabic words attributable to the raise out of note-ruin. In Arabic, there will not be this form of thing as a such factor as note breaks. The letters of a note are connected with every other, so it’s no longer which which it is seemingly you’ll mediate of to ruin a note.

4. Abbreviations #

In English, it’s typical to use abbreviations for, declare, the days of the week. So, “Saturday” turns into “Sat”.

In Arabic, this no longer which which it is seemingly you’ll mediate of at all because a note’s letters are supposed to be connected.

Bidirectional Icons #

Symmetrical icons don’t have to be flipped between LTR and RTL layouts. Right here are some examples:

For some icons, though, it’s critical to flip their direction in RTL layouts, in philosophize that they are going to moreover be clearly understood by the actual person.

Nonetheless, there are continually exceptions. As per the cloth form guidelines, if an icon represents an object that can moreover be held with a particular person’s lawful hand, then it would no longer need flipping. Right here are some examples:

Media Participant Icons #

I went support in time for roughly 15 years ago when my dad got me an MP3 player. It has a play button, and its direction components to the left.

Some icons are widespread, and it would no longer require us to flip them. The reason is that because those playback buttons signify the direction of the tape being performed, no longer the direction of the time. Right here is how Spotify app appears in English and Arabic:

Ogle that the playback icons are no longer flipped since they’re widespread icons.

Messaging Apps #

In an spirited Twitter discussion, I got asked about whether or now to no longer flip the send icon of a messaging app or no longer. I did a bit of research for Facebook Messenger, WhatsApp, and Twitter.

The send icon is flipped, and in my deepest idea, this is the upright factor to achieve because it feels more logical for me. Together with on that, the build of the send and “+” buttons ought to be flipped to invent it more upright. Look beneath mockup:

On the opposite hand, neither Facebook nor Twitter did flip the send icon.

Flipping Ingredients #

While engaged on some components, I desire a technique to swiftly flip them. In the Sketch app, I’ll copy an element and then flip it with the “flip” declare. The same functionality is within the market in Adobe XD and Figma.

To explore what I imply, here’s a GIF showing what I did after flipping an element.

RTL Catch Concerns #

On this portion, I’ll buckle down and do the commonest components and existing how they have to peep in RTL mode.

Button Icons #

It’s typical to have a button with an icon that opens a menu for more actions. On this case, the icon’s build ought to be flipped within the RTL layout.

Form Inputs #

Some produce inputs have to remain left-aligned in RTL — for example, e mail and cell-quantity inputs.

It’s price noting that if the placeholder screech is in Arabic or other RTL language, then the placeholder ought to be aligned to the lawful. Once the enter is concentrated and the actual person begins typing, the alignment shall be flipped to the left.

Thanks to YuanHao Chiang for letting me know relating to the use-case above.

The arrows within the breadcrumb pattern ought to be flipped, too.

A web page header factor contains open and cease sections. Every particular person amongst them ought to be flipped in RTL.

Tables #

A table have to even be flipped.

Tabs #

For a tabs have confidence LTR, the icons could per chance be to the left of the associated price. In RTL, these ought to be flipped.

Card #

For a horizontal card, the affirm of the image and the textual screech ought to be flipped in RTL.

Toasts #

As which it is seemingly you’ll ask, “close” and warning icons have to flipped.

Blockquotes #

The icon ought to be flipped as within the mockup beneath.

CSS Logical Properties #

In response to MDN:

CSS Logical Properties and Values is a module of CSS introducing logical properties and values that offer the flexibility to recall a watch on layout through logical, in preference to physical, direction and dimension mappings.

Let’s choose a straightforward instance. Divulge we’ve got to align a string of textual screech to the left. So, we add the next:

.web page-header {

textual screech-align: lawful;


And for the RTL:

[dir="rtl"] .nav-merchandise {

textual screech-align: left;


What if there used to be a technique to add one textual screech-align price that adjustments the direction based mostly on the web page’s direction? CSS logical properties to the rescue!

.web page-header {

textual screech-align: cease;


By having this, the direction of textual screech-align shall be based mostly on the web page. Demo

To invent it clear-gash to take a look on the adaptation between open and cease, I’ve made the mockup beneath. The open price is such as left in LTR, and cease is such as lawful in RTL. The same applies for cease as properly.

Now that you’ve got a fundamental idea of how it in actuality works, let’s explore more examples and use cases for CSS logical properties.

Logical Padding #

Divulge we’ve got a search enter, with a search icon on the lawful. We have to add padding on each the left and the lawful. The padding on the lawful could per chance be rather greater to quit the textual screech from losing beneath the hunt icon.

.enter--search {  

padding-inline-open: 1rem;

padding-inline-cease: 2.5rem;


Logical Margin #

The margin on the lawful aspect of this icon needs to be logical, so we’ll use margin-inline-open for that.

.web page-header__avatar {  

margin-inline-open: 1rem;


Logical Borders #

Regularly times, which it is seemingly you’ll must add a border to expose that a navigation aspect is active. In the form above, there is a border on the left aspect of each navigation aspect. How will we invent it logical?

.nav__item {  

border-inline-open: 3px actual clear;

} {

border-shade: #1e9ada;


Logical Border Radius #

In the form above, the navigation aspect’s background has a border radius true for the tip-lawful and bottom-lawful corners. In affirm to achieve that logically, we use the next:

.nav__item {  

border-open-cease-radius: 30px;

border-cease-cease-radius: 30px;

background-shade: clear;

} {

background-shade: #ecf6fb;


Logical Properties Cheat Sheet #

When in doubt relating to the logical identical of a directional CSS property, use the cheat sheet beneath. Please present that the properties integrated are little to what’s unswerving for LRT and RTL. I made it based mostly on a spacious article by Adrian Roselli.

Look the Pen
CSS Logical Properties
by Ahmad Shadeed (@shadeed)
on CodePen.

Together with on that, Adrian created a demo that makes it clear-gash to realise the adaptation between a logical and a directional CSS property.

Look the Pen
Logical Properties Mapping
by Adrian Roselli (@aardrian)
on CodePen.

Browser Enhance #

Browser relief is moderately right for padding, margin, and textual screech-align. Nonetheless, it’s no longer right for the border-radius properties. Right here are the aid tables from Can I Dispute:

Support for CSS logical properties from Can I Use website

Support for CSS logical properties from Can I Use website

Though relief is no longer suited (and it received’t ever be suited), I uncover you to use CSS logical properties with fallbacks. As an instance:

.enter--search {  

padding-left: 1rem;

padding-lawful: 2.5rem;

padding-inline-open: 1rem;

padding-inline-cease: 2.5rem;


Also, you will need to use the PostCSS Logical plugin, which provides a fallback for every logical property old fashion.

CSS Naming Conventions #

In typical, attach remote from giving CSS lessons names that are tied to their aspects. Dispute names that can moreover be extracted to reusable components. Take present of the next:

<div class="c-section">

<p><a href="#" class="see-link">Look morea>p>


<div class="c-section">

<p><a href="#" class="see-link">Learn morea>p>


In each sections, the links are the identical but their labels are totally different. In the second portion, explore-link doesn’t invent sense. A actual title could very properly be c-link. The c stands for factor, which I realized from the ITCSS framework.

Now that you’ve got the root, we can discover it to RTL styling as properly. The form mockup beneath has a portion with two children.

As another of giving the aspects presentational names, like .c-web page-header__left and .c-web page-header__right, I’ve named them .c-web page-header__start and .c-web page-header__end. This is more future-proof and doesn’t recall that the accumulate predicament is barely LTR or only RTL.

To my files, the vertical scrollbar direction internal a container in CSS adjustments based mostly on the web page direction. For an RTL layout, the scrollbar direction is on the left, and for LTR, it be on the lawful.

Take present of the beneath figure.

Nonetheless, for operating programs, the browser’s scrollbar would no longer commerce and it stays on the lawful aspect no topic the OS language. However for the operating machine itself, the scrollbar adjustments reckoning on its language.

Automation Instruments #

Huge tools exist to invent our job more straightforward after we’ve got to flip a form from LTR to RTL.

1. Bi-App-Sass #

Bi-App-Sass by Anas Nakawa ability that you can write fashion sheets once, and then it compiles them to two totally different fashion sheets, one for LTR and the opposite for RTL.

This intention could per chance be unswerving for a first-price project. The cease end result could per chance be more than one fashion sheets for every language direction. Take present of the next:

.elem {

present: flex;

@encompass margin-left(10px);

@encompass border-lawful(2px actual #000);


The resulting CSS could per chance be this:


.elem {

present: flex;

margin-left: 10px;

border-lawful: 2px actual #000;



.elem {

present: flex;

margin-lawful: 10px;

border-left: 2px actual #000;


Say, nonetheless, that the leisure commit within the GitHub repository used to be four years ago (November 2015).


RTLCSS by Mohammad Younes is a framework for converting LTR fashion sheets to RTL.

The adaptation with this intention is that it only runs on the form model of a CSS file. As an instance, whilst you happen to have gotten got a project with 50+ Sass components, RTLCSS will reach in to hand for parsing the compiled CSS file and growing an RTL model of it.

Life like Examples #

I’ve designed a layout specially to existing you programs I could per chance way and deem flipping it to a RTL layout.

Let’s open with the header factor. To code it properly, I’ve outlined a typical skeleton. Ogle that I’ve divided the header into a famous portion and subsections. Also, I’ve added open and cease lessons for the sections.



present: flex;

present an explanation for-screech: home-between;


And since CSS flexbox works based mostly on the direction of the web page, as defined beforehand in this files, this could flip robotically for RTL.

The subsequent factor is the dividing line between the emblem and navigation. In the open, I figuring out to be using border-lawful. It in actuality works but is no longer very suited. Using a pseudo-aspect could per chance be better because this could flip based mostly on the web page’s direction.

.c-trace:after {

screech: "";

present: inline-block;

vertical-align: heart;

width: 3px;

top: 38px;

border-radius: 5px;

background: #e4e4e4;

margin-inline-open: 1.25rem;


Right here is the cease end result up to now:

Subsequent, I’ll work on the subjects factor (the one within the subheader with labels and counters). Right here is a form mockup of how the subjects factor have to peep in LTR and RTL. Ogle that the build of the counters is totally different.

It can per chance seem clear-gash within the open, but more than one declarations of padding and margin have to be handled between LTR and RTL. Right here is a mockup illustrating that:

.themes-heading {

margin-inline-cease: 1.5rem;


.themes-list {

margin-inline-cease: 1rem;


.c-topic {

padding-inline-open: 0.5rem;


.c-topic:no longer(:remaining-little one) {

margin-inline-cease: 10px;


.c-topic__counter {

margin-inline-open: 1rem;


As which it is seemingly you’ll explore, I’ve old fashion CSS logical properties, in preference to left and lawful.

The subsequent step is the “Look All” link. Ogle the arrow on the cease of it. Below are its requirements:

  • The arrow’s shade have to commerce on fly.
  • The arrow have to animate to the lawful on fly.

I selected to use inline SVG for this motive. After I added a translate animation to the arrow, I figuring out to be RTL. There’ll not be this form of thing as a logical property for this, and I mandatory to explore other solutions. One solution I got here up with used to be to animate the margins.

.c-link svg {

margin-inline-open: 4px;

transition: 0.15s ease-in;


.c-link:fly svg {

margin-inline-open: 8px;


However animating margins is no longer right for performance, though it in actuality works. The opposite solution is to detect the web page’s direction, and predicament the translate declaration based mostly on that.

.c-link:fly svg {

become: translateX(6px);


.c-header[dir="rtl"] .c-link svg {

become: scaleX(-1);


.c-header[dir="rtl"] .c-link:fly svg {

become: scaleX(-1) translateX(6px);


Ogle that for RTL, I’ve added scaleX(-1) to flip the arrow icon horizontally. That you simply would be in a position to use rotate(180deg) as a replacement, but the scale is more clear-gash to me.

Subsequent is the hunt enter. Right here are the requirements:

  • A search icon must appear on the cease of the enter aspect.
  • The build of the hunt icon have to be dynamic.
.c-enter--search {

background-image: url("records:image/svg+xml...");

background-build: lawful 6px heart;


.c-header[dir="rtl"] .c-enter--search {

background-image: url("records:image/svg+xml...");

background-build: lawful 6px heart;


Also, when the actual person sorts within the hunt field, the textual screech shouldn’t lumber below the icon. To connect remote from this, add padding on both the lawful or left aspect.

.c-enter {

padding-inline-cease: 32px;


Right here is the cease end result up to now for every LTR and RTL:

Subsequent is the cell menu. I will use a hamburger icon to expose the menu. The build of the icon will commerce between LTR and RTL. The same goes for the direction of the translate animation.

Test out the demo on CodePen.

Thanks #

Particular as a result of my critical other, Kholoud, for her actual relief and for discovering out the strategies more than one times. Thanks to each Adebiyi Adedotun Lukman and Šime Vidas for their am



Hey! look, i give tutorials to all my users and i help them!