Why is the <html> tag necessary? | Sololearn: Learn to code for FREE!


Why is the <html> tag necessary?

You can also write code without it

7/11/2018 5:27:39 AM

Ahmad Mugmal

5 Answers

New Answer


Hello, Ahmad Mugmal ! The <html> tag is a container that encapsulates the entire content of the web page, including the <head> and <body> tags. Opening and closing tags <html> in the document are optional, but a good style dictates their indispensable use. Typically, the <html> tag comes second in the document, after the document type definition (Document Type Definition, DTD) is set via the <!DOCTYPE> element. The closing </html> tag should always be the last in the document. https://www.sololearn.com/Course/HTML/?ref=app


.php and .html files are similar, so using <html> tags can help clarify. Also, I think very, very old browsers might get confused if you leave out the <html> tag.


it is the best of the 4 basic tags and it houses everything. css and js cannot stand on their own. they have to be linked to an html file, whether as inline, internal or as external file.


Yes it works in all modern browser if we dont write html or head tags(All modern browser does it for us if we miss or dont write). But its like hit or miss. Specially old browser cant render page if html tag is missed. Also you dont know which browser your user is using. So its good practice to include these tags. Hope this helps☺️☺️.