Tuesday, July 18, 2017

HTML5 - Syntax

     

      The HTML 5 language has a "custom" HTML syntax that is compatible with HTML 4 and XHTML documents published on the Web, but is not compatible with the more esoteric SGML features of HTML 4.

       HTML 5 does not have the same syntax rules as XHTML where we needed lower case tag names, quoting our attributes,an attribute had to have a value and to close all empty elements.


        HTML5 is coming with lots of flexibility and would support the followings: 
  • Uppercase tag names.
  • Quotes are optional for attributes. 
  • Attribute values are optional. 
  • Closing empty elements are optional. 
The DOCTYPE:

        DOCTYPE is older versions of HTML were longer because the HTML language was SGML based and therefore required a reference to a DTD.

       HTML 5 authors would use simple syntax to specify DOCTYPE as follows: 

Note: All the above syntax is case-insensitive.

Character Encoding: 


      HTML 5 authors can use simple syntax to specify Character Encoding as follows:


 Note: Above syntax is case-insensitive.

The <link> tag:
     Note: HTML 5 removes extra information required and you can use simply following syntax:

The <script> tag:
     This is common practice to add a type attribute with a value of "text/javascript" to script elements as follows:

Note: HTML 5 removes extra information required and you can use simply following syntax:

Basic HTML Document:
       
     Let's try to run below basic HTML code. Save it in an HTML file htest.htm using your favorite text editor. Finally open it using a web browser like Internet Explorer or Google Chrome, or Firefox etc. It must show the output.



0 comments:

Post a Comment