Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML5 <html> attributes xmlns, lang, xml:lang

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?

like image 966
ma11hew28 Avatar asked Dec 01 '10 00:12

ma11hew28


People also ask

What is xmlns attribute in HTML?

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.

What is xml lang in HTML?

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.

What is lang attribute in HTML?

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.

How can I set lang in HTML?

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.


1 Answers

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.

like image 86
Pointy Avatar answered Oct 01 '22 16:10

Pointy