Actually, Aashka , it's not the root element. <html> is the root. The doctype declaration is known as a browser preprocessor instruction, and those do not permit attributes. Simple as that. More info here:
<--!... --> it's a comment... So how it can have an attribute??
N <! Doctype HTML>
It's the root of the whole HTML document... If u will add an attribute to it... Nothing will happen because it will not display on the output..!!
Hope it helps.... :)
First let us look at what attribute is, ATTRIBUTE point at a direction of an Html ELEMENT, it tell us more information about HTML ELEMENT.
Example of attribute is source (src) pointing at the direction of an image element (Img).
<--!.....--> is a comment and doesn't need further details, so doesn't require attribute.
Same for Doctype, is a declaration and so doesn't require further attribute.
<!-- --> is a comment. A comment doesn't need to have any attribute. And <!DOCTYPE html> is an instruction to the webbrowser about what version the HTML page is written in. Basically <!DOCTYPE html> means HTML5. HTML4 has three different declaration of <!DOCTYPE>
See more at: https://www.w3schools.com/tags/tag_doctype.asp
<!-- --> is of course a comment and has absolutely nothing to do with the output of your code.
<! DOCTYPE html > is only used once and it is always the first element of the html document but won't run an attribute if any is added to it because to me, it only serves as the signature of an html file.
FirstSoloKiller you probably saw that while playing Sololearn's HTML challenge. Well, let me break it down:
<!DOCTYPE html> means the DOCUMENT TYPE is html, and this kind of document declaration declares HTML 5. It is not an element to be closed or open. It is something semantic or something that gives meaning to the web page. You'll observe that right next to it comes the <html> tag which is always closed. You may write an html document without the doctype tag, it's just that, you haven't specified what "version of language you are speaking exactly."
Likewise, the <!--...--> defines a comment, which is not displayed on the webpage nor affect it in ANY way (note, the 3 dots in signifies whatever thing you type in). Comments are used to explain codes and to make it easier to read. Imagine you have a code about 3000 lines, and you want to adjust something at one of the numerous forms input, commenting each codes will assist you in identifying what you want to correct easily and quickly.