Skip to content

:dir lacks wide support – FIXED ! #256

Open
@r12a

Description

@r12a

This issue is applicable to all languages with RTL orthographies.

Style sheets need to add special rules for RTL styles if they are not supported by logical properties or values.

One approach is to create a second style sheet which, when pulled into an HTML page, overrides styles in the main style sheet with settings for RTL text. This approach is not ideal because it requires maintaining the styles in two separate locations, which can therefore get out of synch, and it requires explicit addition of a call to the second style sheet in every page that will support RTL text.

The `:dir()` pseudo-class avoids these issues by allowing the content author to include the RTL variations in the same style sheet as the others. However, it is not yet supported by all major browser engines.

A workaround that precedes selectors with `:root[dir=rtl] selector_here` can help, but `:dir()` is a better way forward. There also appear to be Shadow DOM implications if this is not supported.

The Gap (2022)

:dir is not interoperably supported by all major browser engines.

[selectors-4](https://www.w3.org/TR/selectors-4/#the-dir-pseudo) Describes the :dir() feature in CSS. [html5](https://html.spec.whatwg.org/multipage/semantics-other.html#selector-ltr) Describes the :dir() feature in HTML.

[Can I Use](https://caniuse.com/css-dir-pseudo) indicates that Gecko supports `:dir()`, but Blink, and Webkit do not. This was confirmed while trying to get this to work recently.

The functionality appears to be available in Blink, but behind a flag.

This simple test below checks whether :dir() causes styling to be changed. The test currently passes for Gecko, but not for Blink or WebKit browsers.

Priority

This pseudo-class significantly improves the process of designing style sheets that can cater for both LTR and RTL pages. It is a valuable enabler for better internationalisation of the Web for the billion or so potential users of RTL scripts. This was therefore marked as Basic.

Tests & results

interactive test, The browser supports :dir() selectors.

Action taken

BlinkWebkit

Outcomes - FIXED !

Gecko, Blink and WebKit browsers now support the :dir selector.

[Can I Use](https://caniuse.com/css-dir-pseudo) now confirms that this has been fixed.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    • Status

      Fixed

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions