If a page loads and then uses javascript to change the language attribute on the <html>
element, could that be detrimental to accessibility? Or do screen readers and other accessibility devices usually let the page load dynamic content before parsing it? And further, does it comply with WCAG 2 3.1.1? I have read this section of the spec and it does not seem to touch on this point.
In this case, the system is a single page web app that loads content in various languages based on user preference. We are also looking into 3.1.2 (adding lang to child elements), but we still need to tag the <html>
element appropriately.
My current plan for implementation is to initially fix the lang to English (since that is the default language) and then change the lang attribute when the user's preferences load.
lang
attribute being added to the html element on the fly. I'll need to test. You can addlang
on the fly to generic DOM elements as needed. – Jason