I don't understand the HTML5 specifications for the lang
and xml:lang
attributes of the opening <html>
tag. Scrolling up a bit, I understand that xmlns
is a "talisman" (has no effect), but what about lang
and xml:lang
? Should they be used? If so, what should they be set to?
The xmlns attribute specifies the xml namespace for a document. Note: The xmlns attribute is required in XHTML, invalid in HTML 4.01, and optional in HTML5.
xml:lang is defined by XML 1.0 as a common attribute that can be used to indicate the language of any element's contents. This includes any human readable text, as well as other content (such as embedded objects like images or sound files) contained by the element in which it appears.
The HTML lang attribute is used to identify the language of text content on the web. This information helps search engines return language specific results, and it is also used by screen readers that switch language profiles to provide the correct accent and pronunciation.
In a nutshell Always add a lang attribute to the html tag to set the default language of your page. If this is XHTML 1. x or an HTML5 polyglot document served as XML, you should also use the xml:lang attribute (with the same value). If your page is only served as XML, just use the xml:lang attribute.
Everything I've seen and heard suggests that you should stick to
<!DOCTYPE html> <html> <head> <meta charset='UTF-8'>
(or whatever character set you actually want). If you want a language associated with the page you can use the "lang" attribute on the <html>
tag.
Since HTML5 is not XML, really, I personally would find it weird to use any xml:
namespace stuff.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With