html5 doctype attributes - html

I have updated my sites doctype from XHTML to HTML5,
I currently have:
<!DOCTYPE html>
<html lang="en-GB" xml:lang="en-GB" dir="ltr" xmlns="http://www.w3.org/1999/xhtml">
my question is, are the attributes xml:lang and xmlns still required as I have migrated from xml to html, i'm thinking not but would like to know if there area any situations in which they should be maintained?
Thanks in advance

Have a look at the global attributes.
You should only use the xml attributes if you have aa xml document (http://www.w3.org/TR/html5/global-attributes.html#the-lang-and-xml:lang-attributes)

Related

HTML: How to initiate HTML document header

I am still pretty new to HTML and programming in general so this is more of a curiosity question but I am asking as I want to use it the right way.
Whenever I have to initiate an HTML document I start it as below and never observed any issues.
However, when I work in Adobe Dreamweaver and create a new document there it always shows me the below initiation.
Of course I can overwrite this but I would like to know what is the difference and when it would make sense to use any of Adobe's suggested attributes or to add something else to my first four lines.
Can someone help me with this ?
My current initiation:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<!-- ... -->
HTML initiation shown in Dreamweaver:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- ... -->
Many thanks in advance,
Mike
<!DOCTYPE html>
This is HTML 5. The current standard.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
This is XHTML 1.0 Transitional. A standard from 2000 designed to combine the transition from HTML 3.2 (1997) to HTML 4 (1998) and XML (which never saw wide use, except while pretending to be HTML 4.
can you explain the single attributes that are different to mine and when it would make sense to use any of them ? Esp. regarding
"PUBLIC",
That isn't an attribute. The PUBLIC portion of a Doctype declaration tells the client where it can download the DTD. (As opposed to the SYSTEM portion which gives it an identifier that it can use to look it up from a local catalogue).
Browsers have never cared about DTDs.
"xmlns",
XML Namespace. It lets you distinguish between elements and attributes that have the same name but are from different specifications.
"http-equiv"
"This is equivalent to an HTTP header with this name"
It is largely a joke. Nothing really implements this except for the character encoding portion of the content-type header and HTML 5 gives much nicer syntax for specifying that.
"content".
The value of the above.
Your first declaration is a HTML5 declaration which is the current standard.
The declaration produces by Dreamweaver is a deprecated XHTML 1.0 Transitional declaration (maybe your Dreamweaver is not up-to-date ?).
See here for more information on doctype

Does HTML 5 need `<html xmlns="http://www.w3.org/1999/xhtml">`

When writing a html 5 doctype, are you supposed to include the <html xmlns="http://www.w3.org/1999/xhtml"> as you did when previously using HTML4 doctype or should a different xhtml be used?
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
HTML5 does not require the use of the xmlns attribute as that is specific to XHTML (which means not even HTML 4 uses it either).
If you're just serving regular HTML5, then you can leave out that attribute entirely:
<!DOCTYPE html>
<html>
The xmlns attribute is only required if you're writing and serving XML-serialized HTML5, aka XHTML5.
No, you don't need to include it. This should be enough.
<!doctype html>
<html>
No you don't. In fact, if you include it, then it isn't HTML5, it's xhtml.
The xmlns part is an XML namespace reference. HTML5 is not XML.
In fact, if you were using that xmlns previously, then you weren't using HTML4 either, you were using xhtml. They're not the same.

How to include multiple XML namespaces in HTML5

I'm trying to include Facebook's OpenGraph new meta tags but when I add the required namespaces that would have worked in XHTML, HTML5 won't validate.
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:og="http://ogp.me/ns#" xmlns:fb="https://www.facebook.com/2008/fbml" dir="ltr" lang="en-US">
Where is the proper place to put these namespaces with HTML5?
There are no namespaces in HTML5 AFAIK:
http://mortalpowers.com/news/no-namespaces-in-html5
There is no proper place in HTML5 for the xmlns:og or xmlns:fb attributes.
(One might argue that there is in HTML5 plus some other spec that modifies the requirements of HTML5. But not in HTML5 proper. Validator.nu and the W3C HTML5 validator don't support the kind of "HTML5 plus some other spec that modifies the requirements of HTML5" configuration that would make the xmlns:og or xmlns:fb attributes validate.)
Use XHTML5 to validate it:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:og="http://ogp.me/ns#" xmlns:fb="https://www.facebook.com/2008/fbml" xml:lang="en">
<!--...-->
</html>

Is this page coded incorrectly for proper HTML?

Learning a bit about the differences between XHTML and HTML, I looked at the source of one of our pages:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
Is this correct? Seems like it’s trying to be a HTML page, but then has a link to an XHTML namespace?
It looks like somebody was using an XHTML doctype, and the associated xmlns attribute:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
And then they heard HTML5 was the shiny new doctype, so they changed to that and ended up with:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" >
Just to make it clear, this is what it should be:
<!DOCTYPE html>
<html>
Your code provided,
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
is perfectly fine. It means that the web page is using XHTML5, an XML serialization of HTML5. If you would like your pages to be rendered as proper XHTML5, though, the content-type header of the page should be sent as application/xhtml+xml; text/html is not allowed in XHTML5.
For practical reasons (especially compatibility with previous IE versions, most notably IE 6), you should use HTML5, not XHTML5, like the following:
<!DOCTYPE html>
<html>
Note, of course, that the xmlns attribute has been removed.

HTML Document type and XML namespace

I understand that in order to instruct the browser how to handle HTML page I need to specify a DOCTYPE... For a page that i built with HTML5 I used the following:
<!DOCTYPE html>
When i am viewing other sites that are using the same DOCTYPE, there is an additional definition inside the <html> tag, such as:
<html dir="ltr" xmlns="http://www.w3.org/1999/xhtml">
What does the xml namespace do that it is needed inside the HTML tag in addition to the DOCTYPE definition?
Thanks!
Joel
If the xmlns attribute is set, it's a XHTML (XHTML5) document.
This indicates a HTML5 document:
HTTP-Header Content-Type: text/html
<!DOCTYPE html>
<html>
And this indicates a XHTML5 document:
HTTP-Header Content-Type: application/xhtml+xml
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
If the webpage is using XHTML5 an does not have the xmlns attribute, it wont be displayed properly (Firefox would display the XML-DOM instead of the page).
HTML5 isn't XML, so the informations in the html tag aren't needed