This one surprised me a bit. Are there browsers that are default Right-to-Left rendering and are going to put English language characters backwards if you don't specify the direction?
This one surprised me a bit. Are there browsers that are default Right-to-Left rendering and are going to put English language characters backwards if you don't specify the direction?
> The directionality of an element (any element, not just an HTML element) is either 'ltr' or 'rtl', and is determined as per the first appropriate set of steps from the following list:
> ... If the element is a document element and the dir attribute is not in a defined state (i.e. it is not present or has an invalid value) ...
> ... The directionality of the element is 'ltr'.
It's not that common to see LTR explicitly specified for the document, but you could imagine some code that either outputs ltr or rtl based on the user's preferences. (Indeed I just checked and twitter puts a rtl there if you're using it in Arabic)
> echo('<html dir="$dir" lang="$lang">')
(or something similar), and they unconditionally include the `dir` attribute without checking if it's already set to the default value a browser would assume.