Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

dir="auto" doesn't work as expected in Firefox

Tags:

html

css

firefox

I'm building a web app, on an input text box I add dir="auto" to autodetect the text direction and it works find both in Chrome and Firefox.

when I display that text later I use dir="auto" in the container (p, span, etc..). it works fine in Chrome but the text is always displayed LTR in Firefox. (If I change it manually to dir="rtl" it works in Firefox, but I want it to be automatic)

how can I fix this ?

like image 653
Gal Ben-Haim Avatar asked Jun 28 '26 22:06

Gal Ben-Haim


1 Answers

Unfortunately, Firefox (Gecko) does not support the HTML5 dir attribute properly, which specifies the element's text directionality. This is a known bug and has been marked resolved on 2012-11-26.

It will be implemented within Firefox20 (Milestone). Firefox20 moves to BETA on Week of 2013-02-18.

You can detect the client's default dir attribute by using gecko's document.defaultView (MDN):

// get ltr or rtl
var dir = document.defaultView.getComputedStyle(document.documentElement,null);
like image 187
mate64 Avatar answered Jul 01 '26 16:07

mate64



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!