HTML 5 – As I Learn
Series – 2
HTML, HEAD, BODY
My first look at HTML 5, the basic elements or tags – HTML, HEAD and BODY –
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>HTML5</title> </head> <body> ... </body> </html>
Looks rather slim and trim. So lets compare the same for the previous version –
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>HTML 4</title> </head> <body> … </body> </html>
Wow! That means lot less to write. The declaration in the DOCTYPE tag are gone, only have to mention the type of document, which is html.
In the HTML tag no need to mention the xmlns attribute (namespace).
The META tag under HEAD tag also requires less – just the charset attribute for character set declaration. No need to mention the content is of type text/html – it is already mentioned in the DOCTYPE.
Now I questioned myself – what about language? Previously the language was mentioned in the DOCTYPE “EN”. What happens in HTML 5?
A little search resulted in –
<!DOCTYPE html> <html lang="en">
So in HTML5 we have to mention the language as an attribute (lang) to the HTML tag. The two letter language code is written in small.