Why is my site getting flagged for "Language of page has not been set"?
Summary
If your site is being flagged for “Language of page has not been set” even though you have declared a language, the issue is usually caused by using the wrong language attribute for your document type. Standard HTML requires lang="en", while XHTML requires xml:lang="en".
Issue
If you notice pages on your site are getting flagged within Accessibility for the accessibility issue "Language of page has not been set," even when you've declared the language of the page, then you need to ensure that you've added the correct language attribute for the type of page.
Environment / Applicability
- Product/Feature: Siteimprove Accessibility module
- Version / Platform: All versions; applies to websites using HTML or XHTML document types
- Audience: Web developers, accessibility specialists, content managers responsible for site markup
- Geographic/Language considerations: Applies to all languages; language code (e.g., en) must match the primary language of the page
Cause
For a standard HTML document, the attribute should be formatted like this:
lang="en"
However, if your document type is XHTML, then you have to use a slightly different language attribute to declare the language of the page. The XHTML language attribute is formatted like this:
xml:lang="en"
Resolution
If you're not sure what document type you're using on your site, then you can usually review the !DOCTYPE declaration at the top of the page when you view the HTML source. If you see some variation of the following, specifically if you see XHTML in the declaration of the document, then your page is an XHTML document:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN"
Validation / next steps
For all variations on doctypes you can review the HTML <!DOCTYPE> Declaration page from W3, which includes the common formats for all doctype declarations.
Key takeaways
- The issue is often caused by a mismatch between document type and language attribute
- Use lang for HTML and xml:lang for XHTML
- Confirm document type using the DOCTYPE declaration
Did you find it helpful? Yes No
Send feedback