WebAIM - Web Accessibility In Mind

E-mail List Archives

Re: Always adding a dir attribute to <html>

for

From: Patrick H. Lauke
Date: Sep 8, 2023 1:15PM


On 08/09/2023 20:08, Ridz Apps wrote:
> Just Iike it is considered to be best practice to always add a lang
> attribute

It's not a best practice, it's an actual WCAG requirement to explicitly
indicate a document's natural language.

> what about dir?

That is optional. The spec actually explicitly defines that in the
absence of the dir attribute on the topmost element (when the element
has "no parent element"), "ltr" is used/assumed

https://html.spec.whatwg.org/multipage/dom.html#the-dir-attribute
https://html.spec.whatwg.org/multipage/dom.html#parent-directionality

P
--
Patrick H. Lauke

https://www.splintered.co.uk/ | https://github.com/patrickhlauke
https://flickr.com/photos/redux/ | https://www.deviantart.com/redux
https://mastodon.social/@patrick_h_lauke | skype: patrick_h_lauke