From what I've read, the correct way to start an HTML5 page is:
<!DOCTYPE html>
<html>
With nothing more in those lines. Is this true? (I'm asking because Visual Studio has more than that.)
(Also, I'm wondering if HTML5 is really the current standard or should I be using XHTML5 or some other version.)
According to the HTML living standard and the W3C spec, the doctype is the required preamble but required for legacy reasons. I quote:
- A string that is an ASCII case-insensitive match for the string
"<!DOCTYPE"
.- One or more space characters.
- A string that is an ASCII case-insensitive match for the string "html".
- Optionally, a DOCTYPE legacy string or an obsolete permitted DOCTYPE string (defined below).
- Zero or more space characters.
- A U+003E GREATER-THAN SIGN character (>).
In other words,
<!DOCTYPE html>
, case-insensitively.
And <html></html>
for a valid document
(Also, I'm wondering if HTML5 is really the current standard or should I be using XHTML5 or some other version.)
It is not the current standard IMHO because it is not finished yet. But this article explains very well 10 reasons for using it now.
Mostly yes. But the HTML5 spec for the <html>
element says
Authors are encouraged to specify a lang attribute on the root html element, giving the document's language. This aids speech synthesis tools to determine what pronunciations to use, translation tools to determine what rules to use, and so forth.
so better, for a page whose content is in American English, would be
<!DOCTYPE html>
<html lang="en-us">
Also if you are using XHTML5 served as application/xhtml+xml
you will need to add the namespace, and also the XML equivalent of the lang attribute making it:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-us" xml:lang="en-us">
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