HTML5 Tutorial
- HTML5 – Home
- HTML5 – Overview
- HTML5 – Syntax
- HTML5 – Attributes
- HTML5 – Events
- HTML5 – Web Forms 2.0
- HTML5 – SVG
- HTML5 – MathML
- HTML5 – Web Storage
- HTML5 – Web SQL Database
- HTML5 – Server-Sent Events
HTML5 Demo
HTML5 – Home
HTML5 – Overview
HTML5 – Syntax
HTML5 – Attributes
HTML5 – Events
HTML5 – Web Forms 2.0
HTML5 – SVG
HTML5 – MathML
HTML5 – Web Storage
HTML5 – Web SQL Database
HTML5 – Server-Sent Events
HTML5 – Syntax
The HTML 5 language has a “custom” HTML syntax that is compatible with HTML 4 and XHTML1 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 comes with a lot of flexibility and it supports the following features −
- Uppercase tag names.
- Quotes are optional for attributes.
- Attribute values are optional.
- Closing empty elements are optional.
The DOCTYPE
DOCTYPEs in 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 a simple syntax to specify DOCTYPE as follows −
<!DOCTYPE html>
The above syntax is case-insensitive.
Character Encoding
HTML 5 authors can use simple syntax to specify Character Encoding as follows −
<!DOCTYPE html> <html> <head> <title>HTML Tables</title> </head> <body> <table border = "1"> <tr> <td>Row 1, Column 1</td> <td>Row 1, Column 2</td> </tr> <tr> <td>Row 2, Column 1</td> <td>Row 2, Column 2</td> </tr> </table> </body> </html>
public class App { public static void main(String[] args) throws Exception { System.out.println("Hello, Abhimanyu Panwar!"); System.out.print("Hello Desi Boy"); } }
<meta charset = “UTF-8”>
The above syntax is case-insensitive.
The <script> tag
It’s common practice to add a type attribute with a value of “text/javascript” to script elements as follows −
<script type = “text/javascript” src = “scriptfile.js”></script>
HTML 5 removes extra information required and you can use simply following syntax −
<script src = “scriptfile.js”></script>