Shiny: Shiny HTML element has no lang attribute

Created on 24 Apr 2020  路  5Comments  路  Source: rstudio/shiny

System details

  • Shiny 1.4.0.9002
  • R 3.6.3

Repro Steps

  • Create a simple Shiny App following tutorials or use the default template created in the RStudio IDE (New Project / Shiny Web Application)
  • Run the app and load into browser (I'm using Chrome on macOS)
  • Examine the HTML or run an accessibility validation tool such as Axe (https://www.deque.com/axe/axe-for-web/)

Problem

The HTML element has no lang attribute. This is a WCAG 2.1 A violation: https://www.w3.org/TR/WCAG21/#language-of-page

Expected

Pages should be accessible by default. Thus, there should be a reasonable default, and the ability to specify a different language. For English:

<html lang="en">

This is critical for screen readers, otherwise you can have (for example) a Spanish user's screen reader trying to pronounce English words using Spanish language rules.

There was a community question on this:
https://community.rstudio.com/t/how-to-specify-the-language-to-a-shiny-app/26472

Accessibility

All 5 comments

Making shiny more accessibility friendly would be huge. There is some discussion on it also in issue #2494 regarding alt text.

What would you suggest - adding 'en' by default and exposing it as a parameter to fluidPage and other similar top-level page tags?

By the way, anyone can add this to their shiny apps by just including anywhere in the UI the line

tags$html(lang="en")

@daattali Nice, thanks for the tip! Just need to make that more prominent in our documentation and included in our examples and templates and that's probably sufficient.

By the way, anyone can add this to their shiny apps by just including anywhere in the UI the line

tags$html(lang="en")

Yes, that's possible; however, having document-level lang attribute would be ideal; local use of lang attribute should be limited to only when there is a language change to force screen readers to switch different speech synthesizers. Let me take care of this issue.

Was this page helpful?
0 / 5 - 0 ratings