Tuesday, December 9, 2014

HTML5 Shortcuts


HTML 5 is somewhat looser in its requirements for markup compared to XHTML, allowing a number of shortcuts:
  • Tags can be written uppercase, lowercase, or in mIxEd case.
  • You can drop a lot of closing tags: </li></dt></dd></tr></th></td></thead></tfoot></tbody></option></optgroup></p> (in most cases), </head></body> and </html> not required.
  • Attribute values only need to be quoted if they contain spaces or some non-alphanumeric characters (such as a question mark). So <div id=wrapper> is legitimate, as is <img src=assets/images/falls.jpg …> but <img alt=Angel Falls …> is not.
  • You can eliminate http: at the start of links becomes <a href=//example.com> (This is not specific to HTML5, but it is fun all the same).
You will see these shortcuts used in some code examples on this blog in order to save space.

1 comment: