Mastering RTL Layouts in CSS with Drupal 10: A Complete Guide

Profile picture for user Firas Ghunaim
Firas Ghunaim

Ensuring your site is accessible and user-friendly across different languages and cultures is paramount. This is especially true for websites that cater to languages written from right to left (RTL), such as Arabic, Hebrew, and Persian. Drupal 10, the latest iteration of the robust CMS, has made strides in internationalization, providing extensive support for RTL languages.

Drupal 10 continues its tradition of being an inclusive, language-aware CMS, offering out-of-the-box support for RTL languages. This means that themes and modules within Drupal 10 are designed to automatically adjust their layout when an RTL language is detected.

However, to leverage this feature fully, your website's CSS must be meticulously crafted and tested for RTL compatibility.


Understanding RTL Support in Drupal 10

Creating an Arabic website with Drupal 10 involves detailed steps to ensure the site is fully optimized for Right-to-Left (RTL) layout. Below, I'll guide you through setting up an RTL layout for an Arabic website using Drupal 10.

Related: 10 Key Strategies for Arabic Websites and User Engagement 


Step 1: Setting Up Drupal for Arabic Language

Firstly, ensure Drupal 10 is installed and running on your server. Next, we’ll add the Arabic language and set it as the default language.

  1. Navigate to the Admin Panel: Go to Manage > Configuration > Regional and language > Languages.
  2. Add Language: Click on "Add language" and select "Arabic" from the list. Drupal will automatically import the Arabic translation and set it as the default language if you choose.


Step 2: Enabling RTL Support in Your Theme

Ensure your theme supports RTL. Many Drupal themes, including Bartik, automatically adjust for RTL languages. If you’re using a custom theme, you may need to add RTL support manually.

  1. Check for RTL.css File: Look in your theme directory for an rtl.css file. This file should contain all the overrides necessary for RTL display.
  2. Create or Update rtl.css: If it doesn’t exist, create an rtl.css file. Use it to override CSS properties that are direction-dependent. Here’s how you might flip the layout:


/* style.css */
body {
  direction: ltr;

/* rtl.css */
body {
  direction: rtl;


Step 3: Customizing CSS for RTL Layout

Adjust CSS properties related to layout direction. You might start with a basic CSS file (style.css) and then override specific styles for RTL in rtl.css.

/* style.css */
.content {
  margin-left: 20px;

/* rtl.css */
.content {
  margin-right: 20px;
  margin-left: 0;


Step 4: Utilizing CSS Logical Properties

To simplify maintenance of RTL styles, use CSS logical properties that adapt to the direction of the content, reducing the need for separate RTL overrides.

.content {
  margin-inline-start: 20px;


This property applies a margin to the start of an element, automatically adjusting for RTL or LTR content direction.


Step 5: Loading the RTL Stylesheet

Drupal automatically applies an RTL stylesheet if the active language is RTL. Ensure your theme’s .info.yml file correctly defines the RTL stylesheet to be loaded.

    - css/style.css
    - css/rtl.css


Step 6: Testing Your Site

After implementing the RTL styles, thoroughly test your site:

  • Use the language switcher to switch between Arabic and any LTR languages you support.
  • Pay close attention to layout, text alignment, forms, navigation, and any custom components.
  • Use browser developer tools to debug and fine-tune your RTL styles.


FAQs on RTL Layouts in CSS with Drupal 10

  • Q: Do all Drupal 10 themes support RTL out of the box? Most themes do, but the extent of support can vary. Always check theme documentation and test extensively.

  • Q: Can I use a single CSS file for both LTR and RTL styles? While possible, it's best practice to separate these into different files for clarity and maintainability.

  • Q: How can I ensure my custom modules are RTL compatible? Follow the same principles outlined here—use logical properties and conditionally load RTL-specific styles.


Multilingual Digital Experiences: Conclusion

Creating an Arabic RTL website in Drupal 10 requires careful attention to language setup, theme selection, and CSS customization for RTL support. By following these steps and utilizing CSS logical properties, you can ensure a seamless user experience for Arabic-speaking users. Remember to test your site extensively in both RTL and LTR modes to catch and correct any layout issues.

Need help designing your Arabic website? We can help. Contact us today to explore your opportunities.


Author Bio

Firas Ghunaim is an experienced digital marketer with 12+ years worth of expertise in the digital transformation industry. Ghunaim is specialized in building high performance multilingual websites that help businesses generate organic traffic and growth.