Skip to content

Bootstrap RTL: the complete guide

Set up Bootstrap's RTL stylesheet, use start and end utilities, and debug custom CSS, nested direction, dropdowns and Arabic forms.

By , Founder of Ritla

Guide14 min read

A Bootstrap page can move its columns to the right while leaving a card's accent border on the left. An Arabic dropdown can align correctly until another route loads the ordinary Bootstrap stylesheet. Neither problem is fixed by reversing every flex row.

Bootstrap RTL combines document direction with a separately generated stylesheet. Its start and end class names describe intent, but many declarations in the distributed CSS still use physical sides. Custom styles outside the generation process keep whatever assumptions their author wrote.

This guide uses Bootstrap 5.3 and a museum's manuscript-conservation portal. It covers the RTL build, utilities, custom CSS and interactive states. Older Bootstrap classes and third-party themes need their own version review; they do not become compatible just because the page loads a newer RTL file.

Load one matching Bootstrap build for the document#

For an Arabic page, declare language and direction on the root element and load bootstrap.rtl.min.css. The following starter pins Bootstrap 5.3.8, the release shown in the current Bootstrap RTL documentation:

html
<!doctype html><html lang="ar" dir="rtl"><head>  <meta charset="utf-8">  <meta name="viewport" content="width=device-width, initial-scale=1">  <title>طلبات ترميم المخطوطات</title>  <link rel="stylesheet"    href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.8/dist/css/bootstrap.rtl.min.css"    integrity="sha384-CfCrinSRH2IR6a4e6fy2q6ioOX7O6Mtm1L9vRvFZ1trBncWmMePhzvafv7oIcWiW"    crossorigin="anonymous"></head><body>  <main class="container py-4">    <h2 class="mb-3">طلبات ترميم المخطوطات</h2>    <section class="card" aria-labelledby="conservation-status">      <div class="card-body">        <h3 id="conservation-status" class="h5">فحص الغلاف الجلدي</h3>        <p class="mb-0">بانتظار صور توضح مواضع التلف.</p>      </div>    </section>  </main>  <script    src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.8/dist/js/bootstrap.bundle.min.js"    integrity="sha384-FKyoEForCGlyvwx9Hj09JcYn3nv7wiPVlz7YYwJrWVcXK/BmnVDxM+D2scQbITxI"    crossorigin="anonymous"></script></body></html>

The bundle supports the interactive examples later in this guide and includes Popper. Keep CSS and JavaScript on the same release. If upgrading the CDN URLs, copy the matching integrity values too; an old hash can prevent the browser from accepting the new asset. Bootstrap's getting-started guide documents the distributed files.

For an npm application with a bundler that handles CSS imports, select the equivalent package files instead of adding the CDN tags as well:

js
import 'bootstrap/dist/css/bootstrap.rtl.min.css';import 'bootstrap/dist/js/bootstrap.bundle.min.js';

The package must already be installed at the chosen compatible version. Use this as an alternative entry point, not another copy of Bootstrap alongside the starter.

Load the ordinary build on the English document and the RTL build on the Arabic document. Do not load both unscoped stylesheets globally and rely on whichever one happens to come last. Conflicting declarations can remain active on both sides, so changing their order is not equivalent to selecting a direction.

The duplicate-build failure is visible on a simple spacing utility. If one build assigns a left margin and the other assigns a right margin, both declarations can survive because they address different properties. Moving a link element later does not unset the other margin. Select an affected element in developer tools and inspect both physical sides, then trace each winning declaration to its asset. Remove the unintended framework import at its source before evaluating any compensating component overrides.

Inspect network requests and the final bundled CSS when results disagree with the template. A layout, theme package or route-level import may bring the ordinary build back. Search imports as well as link elements; a bundled copy will not necessarily have a recognizable filename in the rendered document.

Verify HTML direction independently of the stylesheet#

The RTL file changes Bootstrap's styles. It does not assign the document's base direction or identify its language. Conversely, lang="ar" does not set RTL layout.

The W3C direction guidance explains the role of dir in HTML. Put it on the root for the Arabic document rather than applying CSS direction to scattered components. R001 covers document direction missing, contradicted, or declared only in CSS.

Check the initial HTML and the live document. A browser-only direction update after rendering can conceal a wrong first response. Inspect computed direction on the card, an input and an open overlay too; a local override can contradict the root even when the document attributes are correct.

When diagnosing, write down the active build and the element's direction separately. An RTL document with LTR Bootstrap CSS can look partly mirrored because browser layout and framework spacing follow different inputs. Adding more right alignment makes that disagreement harder to trace.

Keep an English version of the same conservation card available. Use the same title, content length and interaction state for comparisons where possible. Changing both the data and the direction makes it harder to tell whether a defect comes from wrapping, styling or translation.

Use start and end utilities with the correct expectations#

Bootstrap 5 replaces several older left/right utility names with start/end names. Use the current classes consistently instead of preserving a second naming system in application templates.

IntentBootstrap 5 class examples
Margin at reading startms-3, ms-lg-4
Padding at reading endpe-3, pe-md-4
Text aligned to reading starttext-start
Absolutely positioned at reading endend-0

The spacing documentation defines the notation and responsive variants. The migration guide covers the move from older class names. In a Bootstrap 5 migration, check whether a legacy class actually has a rule before blaming RTL.

These names do not guarantee native logical declarations in the compiled build. For example, Bootstrap 5.3.8's ordinary CSS defines .ms-3 using margin-left; its RTL counterpart uses the opposite side. The build supplies the mapping. A nested dir change does not rewrite an already compiled physical margin.

Inspect the winning declaration rather than guessing from the class name. This also applies to alignment: compare the framework's text utilities with native text-align: start. They can express similar intent while reaching the browser through different declarations.

Utilities can carry !important, so a later application rule may still lose. Remove an incompatible utility when transferring ownership to a component class, then inspect computed styles again. Increasing selector length without checking importance does not resolve that conflict.

Responsive variants add a second condition to inspect. A margin that is correct on a narrow conservation card may be replaced when a larger-breakpoint utility becomes active. Resize across the breakpoint in the installed build and watch the winning rule change. Record the active media query with the computed value. Repairing only the base utility or adding an override at the wrong breakpoint leaves the defect waiting for a wider screen.

A nested LTR region does not select the other Bootstrap build#

The museum portal may show an English cataloging note inside an Arabic page. Its text needs an LTR boundary, but that boundary does not load English Bootstrap styles for the region.

For example, this note still receives the RTL build's utility declarations:

html
<aside lang="en" dir="ltr" class="text-start ms-3">  Binding assessment awaits specialist review.</aside>

The intended result is English text aligned to its reading start with indentation at that same start. Under the global RTL build, the physical declarations behind those classes do not automatically change to match the aside's local direction.

For this small custom region, remove the conflicting utilities and use native logical CSS:

html
<aside lang="en" dir="ltr" class="catalog-note">  Binding assessment awaits specialist review.</aside>
css
.catalog-note {  text-align: start;  margin-inline-start: 1rem;}

Load this application rule after Bootstrap. The logical-properties specification defines direction-relative margins, and MDN's text-alignment reference explains start. In the ordinary LTR build, the replacement preserves the original left indentation. It also follows the local LTR boundary within the Arabic page.

Check the actual element's computed direction and margins. A child that sets another direction establishes another mapping; reading start belongs to the styled element, not automatically to the document.

A whole nested Bootstrap application is a larger integration. Bootstrap documents generating scoped LTR and RTL styles, with limitations, in its RTL guide. Do not approximate that by including both global builds. For a short foreign-language note, a local direction boundary and a small application class are easier to inspect. See nested LTR content inside RTL pages when the boundary contains more than a note.

Let the grid follow direction before adding order overrides#

Bootstrap's standard grid is based on flexbox. An ordinary horizontal flex row follows the element's direction. Switching the document to RTL already changes where the first column begins; reversing the row adds a separate ordering decision.

This conservation workspace keeps the assessment before its supporting photographs in the markup:

html
<div class="container">  <div class="row g-3">    <section class="col-12 col-lg-8" aria-labelledby="binding-review">      <h2 id="binding-review" class="h4">تقييم حالة التجليد</h2>      <p>سجّل ملاحظات الفحص قبل إحالة المخطوط إلى المختص.</p>    </section>    <aside class="col-12 col-lg-4" aria-labelledby="damage-photos">      <h2 id="damage-photos" class="h4">صور مواضع التلف</h2>      <p>أرفق صور الغلاف والحواف والصفحات المتضررة.</p>    </aside>  </div></div>

In the wide RTL layout, the first section begins on the right. At the stacked layout, its position in the document still determines which section comes first. Bootstrap's grid documentation explains its layout model and breakpoints.

Do not add flex-row-reverse to make this Arabic. Review any existing order-* utilities against the intended reading sequence. A desktop visual rearrangement can leave mobile content or keyboard navigation in an unexpected sequence. R081 covers flex row-reverse faking RTL instead of dir; test the actual tab sequence separately.

Custom flex layouts can use gap-* when spacing means separation between siblings rather than an outside margin. Bootstrap's flex utilities cover direction and wrapping. Use a spacing model that matches the layout instead of repairing each child with a different side-specific margin.

For horizontal overflow, inspect the row's gutter compensation before changing direction. Bootstrap gutters use column padding and negative row margins. A row placed in an unsuitable wrapper or given enlarged gutters can exceed its available space. Check the container and row together; hiding overflow on the entire page can conceal clipped content and controls.

Repair application CSS at its own source#

Loading Bootstrap RTL does not transform a stylesheet written beside it. An inline style attribute also remains outside the framework's compiled CSS.

Suppose the conservation card uses an accent at reading start. This application rule preserves the English appearance but leaves that accent on the wrong side in Arabic:

css
/* Problem: ordinary application CSS loaded after Bootstrap. */.conservation-note {  border-left: 4px solid #80582f;  padding-left: 18px;}

Moving only the text does not move the border. Adding an RTL right border without removing the left one can create accents on both sides. Express the relationship directly:

css
.conservation-note {  border-inline-start: 4px solid #80582f;  padding-inline-start: 18px;}

The LTR border and padding stay on the left; horizontal RTL maps them to the right. Replace the physical declarations rather than retaining both sets and hoping the cascade selects the intended edge. R030 covers direction-sensitive physical properties without an RTL override.

Trace every disputed property to its source. It might come from Bootstrap, a theme, a plugin, an inline style or the application's own stylesheet. Temporarily disable the winning declaration in developer tools. If that restores the expected card geometry, repair that source rather than changing global direction.

Physical coordinates can still be intentional. An annotation aligned with a tear in a scanned manuscript should stay attached to the same image feature in both languages. Record that coordinate as a physical exception and test it against the image. Do not mirror the scan itself to make the surrounding controls look Arabic.

Absolute-position helpers deserve the same distinction. Bootstrap's position utilities include start-*, end-* and translation helpers. Inspect their generated declarations and transforms when combining them with custom coordinates. For a deeper positioning repair, use absolute positioning in RTL layouts.

Know which files enter the RTL generation process#

Bootstrap's RTL build is produced with RTLCSS. That transformation happens before the browser uses the stylesheet. It is not a runtime service that observes all CSS on the page.

If the portal customizes Bootstrap from Sass, decide whether its application rules belong in that same output or in a separately maintained stylesheet. Bootstrap's Sass customization guide explains the framework's variables, maps and import structure. Keep a clear boundary between generated assets and rules supplied later.

Rule sourceWhat to verify
Distributed Bootstrap CSSSelected LTR or RTL asset and release
Custom Sass included in the transformed outputResult after Sass and RTL processing
Separate application CSSLogical properties or explicit direction treatment
Inline styles and third-party widgetsTheir own direction contract

Generate the two framework variants from the same customization source. Otherwise, a palette or spacing change can reach English while Arabic keeps an older build. Compare build identifiers and representative component rules when the two versions drift.

Check the deployed response as well as the files produced locally. An asset URL that keeps the same name across releases can be served from a cache after its contents change. Use the project's existing asset-versioning mechanism for both variants, and confirm which response the Arabic document receives. If the local build contains a repaired rule but the browser receives an older one, another CSS override would address the wrong problem.

Avoid applying RTL transformation twice or manually swapping a physical declaration before also feeding it through the transformation. Inspect the final rule, including exception directives, rather than treating the source as proof of the output. Minification or comment removal must not erase processing instructions before the step that needs them.

Do not edit the generated minified RTL file as the permanent repair. The next build replaces it, and the equivalent LTR rule becomes harder to maintain. Keep the change in Sass, application CSS or the relevant plugin configuration, then rebuild both directions. Bootstrap's optimization guidance also explains selecting the framework parts the product uses.

Test dropdown alignment with the JavaScript running#

A closed dropdown tells you little about its menu. Test the open state using the same Bootstrap JavaScript and positioning configuration that ships to users.

Here is a conservation-file action menu to place inside the starter's body:

html
<div class="dropdown">  <button class="btn btn-outline-primary dropdown-toggle" type="button"    id="conservation-actions" data-bs-toggle="dropdown" aria-expanded="false">    إجراءات ملف الترميم  </button>  <ul class="dropdown-menu dropdown-menu-end"    aria-labelledby="conservation-actions">    <li><button class="dropdown-item" type="button">إحالة إلى مختص الورق</button></li>    <li><button class="dropdown-item" type="button">طلب صور إضافية</button></li>  </ul></div>

The menu opens with the bundle loaded. Connect the item buttons to the portal's existing referral and photograph-request actions when integrating it.

dropdown-menu-end means alignment to the corresponding end in the selected build. Bootstrap's dropdown documentation states that this alignment is mirrored in RTL. Do not change it to another class merely because the physical edge differs from English.

Inspect the menu next to both viewport edges. Test a long Arabic item, keyboard opening and closing, and focus after dismissal. Popper can influence placement when space is constrained, so compare the final positioned menu rather than only the stylesheet's initial edge declarations.

Responsive dropdown alignment has a documented configuration of its own. If the product uses it, follow the component's requirements, including static display where required, rather than mixing breakpoint classes with assumed dynamic placement.

Apply the same open-state discipline to modals and offcanvas panels. Verify their close buttons, content wrapping, backdrop and focus behavior. Follow the modal documentation when moving markup out of a clipping or transformed ancestor; changing its DOM location can also change inherited direction. A custom widget placed outside a locally Arabic wrapper needs its own ancestry review.

Keep field geometry and editable-value direction separate#

Bootstrap's form classes style the control; they do not determine the appropriate direction for every kind of value. An Arabic observation field and a collection-system URL have different content contracts.

For the external catalog URL, set direction on the input while leaving its Arabic label in the surrounding RTL context:

html
<label for="catalog-source" class="form-label">رابط سجل المخطوط في الفهرس</label><input id="catalog-source" name="catalogSource" type="url" dir="ltr"  class="form-control" value="https://collections.example.org/manuscripts/binding-review"  aria-describedby="catalog-source-help"><div id="catalog-source-help" class="form-text">  أضف رابط السجل الذي يستخدمه فريق الفهرسة.</div>

Leave ordinary Arabic observations in the page's RTL context. Applying LTR to the entire form to accommodate this URL changes the boundary for unrelated labels and fields. R070 covers telephone, email and URL inputs rendered RTL; it does not justify forcing Arabic text entry to LTR.

Test typing, selecting and replacing the URL, then test the Arabic observation field independently. Bootstrap's form-control documentation covers the component styling. Use Arabic text input direction for the content-specific direction decisions.

Input groups need another check: changing the whole group's direction can change the arrangement of its attached elements, while changing only the native input targets its editable value. Inspect borders, joined corners and the text boundary in the rendered result. The input-group documentation explains its structure and label placement.

Translate validation messages and accessible labels through the application. Neither the RTL stylesheet nor an Arabic lang attribute translates arbitrary English strings in templates. Test empty, invalid and server-rejected states instead of reviewing only a filled form.

Review typography, icons and text that CSS cannot translate#

The RTL stylesheet does not supply an Arabic font file. Check rendered glyphs after fonts load, including the weights used by headings, buttons and form controls. R050 covers Arabic text falling back past the declared font family. A font-family name in a theme is not evidence that the intended font reached the browser.

Remove inherited Latin display treatments where they harm Arabic labels, and inspect line height before imposing a fixed control height. Test the long conservation-file title in a narrow card and the menu's longest translated action. The replacement font can change wrapping after the initial render.

Custom SVGs and image assets need semantic review. A navigation arrow may depend on the sequence it advances; a scan, signature or museum mark has a fixed orientation. Do not mirror the whole component to move one icon. Use what should be mirrored in RTL for those decisions.

Bootstrap's accessibility guidance explains the author's role in accessible content and behavior. Inspect close-button names, visually hidden action text and tooltip content alongside visible Arabic labels. Replacing a visible heading does not establish that the controls beneath it are translated.

Switch direction as a document-level integration#

For separate Arabic and English pages, let the server or document template select the corresponding stylesheet with the matching lang and dir. Verify each URL directly, including refreshes and deep links.

A client-side language switch needs to coordinate text, document attributes and stylesheet selection. Updating only dir leaves build-specific utilities unchanged. Updating only the CSS leaves browser direction inconsistent with the framework. Wait for the required assets and handle loading failure before presenting the new language as ready.

Test the switch with a dropdown open, a populated observation field and a validation error visible. Decide which temporary overlays should close, preserve unsent observations, and check focus after the change. Bootstrap's JavaScript guide documents component methods and lifecycle events; do not assume every positioning state is recalculated simply because an attribute changed.

Check browser back and forward navigation as well. The restored document attributes, active stylesheet and translated interface should describe the same locale. A successful first toggle does not establish that the reverse transition or restored page works.

Verify the portal through its deployed interactions#

Keep a small reproduction when a Bootstrap component fails. Remove unrelated themes and application overrides, retain the same framework version, and compare it with the failing portal. If the isolated component works, add the extra styles back until the responsible declaration or import becomes visible.

  • Confirm that the Arabic response loads one matching Bootstrap build and declares root direction.
  • Inspect utilities at their active breakpoints, including any nested LTR regions.
  • Compare the conservation assessment and photograph panels in wide and stacked layouts.
  • Open menus and overlays, then test keyboard operation and focus return.
  • Exercise Arabic observations and technical URL fields in empty, filled and invalid states.
  • Check custom borders, coordinates and icons against their intended meaning.
  • Repeat direct loads, language switches and navigation against the production build.

When documenting a failure, record the active asset, computed direction, winning declaration, viewport and interaction state. That evidence distinguishes an incorrect framework build from a custom override or a component that needs more space.

Use keyboard and visual checks together. A menu can contain the right Arabic text yet place focus somewhere unexpected after dismissal. A field can expose the expected accessible name while its helper text is clipped. Test each of those outcomes directly rather than treating a text assertion or a screenshot as evidence for both. Keep the same manuscript request throughout the journey so that a change in content does not obscure a direction-dependent regression.

A free Ritla scan of the Arabic conservation page can surface direction-sensitive physical properties without RTL overrides, including custom rules left outside Bootstrap's RTL build. Continue with debugging RTL layout problems to trace a remaining override, or nested LTR content inside RTL pages when a foreign-language region behaves differently from the surrounding components.

Checks in this guide

See what your Arabic pages are hiding

Paste a URL. Ritla renders the page on desktop and mobile, runs every check, and shows the top issues with screenshot evidence.

Scan a page freeBrowse the checks