Search code examples
htmlaccessibilityscreen-readerslang

HTML language code


I have small sections of text on my site that are in French (Canadian). When I look up on the W3schools language code reference, I find there is only a list of specific languages but not location. Is writing <span lang="fr-CA"> valid? Does adding the location-base of the language have any impact at all on screen-readers?


Solution

  • The next reference on W3schools describes valid country codes and how to use them with language codes.

    Ex: <html lang="en-US">

    In regards to screen readers, it would depend on how the reader was implemented. Generally they would get the language from <html> but it is possible that some implementations may allow for the language to change over the course of the document.

    The lang attribute can be used in any html element, as described in the HTML specifications, so <span lang="fr-CA"> would be valid.