Is it still necessary (or even good practice) when using HTML5 to declare the script type when using a script block?
e.g. <script type="text/javascript">
Plus what about using a CDATA block in the script for browser parsing?
e.g. // <![CDATA[ ... ~code here ~... // ]]>
Any help much appreciated.
The <! DOCTYPE html> declaration is used to inform a website visitor's browser that the document being rendered is an HTML document. While not actually an HTML element itself, every HTML document should being with a DOCTYPE declaration to be compliant with HTML standards.
Scripts can be placed in the <body> , or in the <head> section of an HTML page, or in both.
<! DOCTYPE html> // Tells the browser that we are using HTML5. If document type is not mentioned, browser will go to Quirks mode. Quirks mode depends upon the web browser version, If is older version then this will not support HTML5 tags (Example: header tag, footer tag, section tag,...)
Definition and Usage All HTML documents must start with a <! DOCTYPE> declaration. The declaration is not an HTML tag. It is an "information" to the browser about what document type to expect.
The current draft of HTML5 doesn't require the type attribute for script tags.
Also the <![CDATA
is not required in HTML5 (it was XHTML specific anyway).
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