HTML5 Document Structure
General HTML 5 Document Structure is as below
1 2 3 4 5 6 7 8 9 | <!DOCTYPE html> <html lang="en"> <head> ... </head> <body> ....... </body> </html> |
<!DOCTYPE html> specifies that this document is HTML5 document and you can use all html5 tags here.
<html> is root tag of HTML document it contains two child tags <head> and <body>
<head> specifies that this portion contains heading information of the page we can use many other tags here like <title> which is used to specify the title of the page and many others.
<body> we put the contents which you would like to display on the browser.
Inside the body tag, we use many different HTML tags to proper formatting the data like p,heading tags, and image.
HTML logo png
Find HTML5 LOGO Here
Example
1 2 3 4 5 6 7 8 9 | <!DOCTYPE html> <html lang="en"> <head> <title>My First Html Page</title> </head> <body> <h2>Welcome to my first html page</h2> </body> </html> |
In the above syntax start and end tags are optional.
if you don’t want to use an attribute with the root tab ie <html lang=” en”> then you can omit this
So syntax without root tag
1 2 3 4 5 6 7 | <!DOCTYPE html> <head> ... </head> <body> ....... </body> |
Example of HTML5 Document Structure
Example
1 2 3 4 5 6 7 | <!DOCTYPE html> <head> <title>My First Html Page</title> </head> <body> <h2>Welcome to my first html page. Removed root tag</h2> </body> |
In the XHTML syntax, we have to specify the xmlns to declare that it is an HTML namespace.
We can use lang or xml:lang attribute to specify the language
Syntax with xmlns
1 2 3 4 5 6 7 | <html xmlns="http://www.w3.org/1999/xmlns" xml:lang="en"> <head> ... </head> <body> ....... </body> |
Example
1 2 3 4 5 6 7 8 | <html xmlns="http://www.w3.org/1999/xmlns" xml:lang="en"> <head> <title>My First Html Page</title> </head> <body> <h2>Welcome to my first html page. Removed root tag</h2> </body> </html> |
Example
1 2 3 4 5 6 7 8 9 10 11 | <!DOCTYPE html> <!DOCTYPE html> <html lang="en"> <head> <title>My First Html Page</title> </head> <body> <h1 style="background-color:cyan;font-size:20px">Welcome to my first html page</h1> <p>Keep learnig html5 its simple and easy </p> </body> </html> |
Read More