HTML Cheat Sheet for Transition to HTML 5

Tag and Attribute Coding

Definition: Polyglot HTML Documents: HTML documents that can be parsed as either text/html or as an XML type such as application/xhtml+xml.

Tags

Properly Nested Tags

<p>...</p>  <p>...  <P>...</P>
<tr><td>...</td></tr>  <tr><td>...</tr></td>

Empty Tags

<br/>  <br>
<hr/>  <hr>
<img src="example.png" alt="example"/>
<img src="example.png" alt="example">

Attributes

Quoted Attributes

<abbr title="Hypertext Markup Language">HTML</abbr>
<a href=http://www.ExampleOnly.com/> <!-- ambiguous -->
<a href="http://www.ExampleOnly.com/"> <!-- / is part of
URL -->
<p id=back-to-top>
<p id="back-to-top">

Style Attributes

<table width="100%">
<table style="width: 100%">
<table class="wide">

Boolean Attributes

<option selected="selected"/>
<option selected/>
<option selected=""/>
<option selected="true"/>
<option selected="yes"/>

Definitions of Acronyms and Abbreviations

Defined term, not definition, in title attribute

A <dfn title="short for weblog">blog</dfn> is an online journal.
A <dfn title="blog">blog or weblog</dfn> is an online journal.
A <dfn>blog</dfn>, short for <dfn>weblog</dfn>, is an online journal.

<dfn> gets default title from an <abbr> tag that is its only content

<dfn><abbr title="National Association for Stock Car Auto Racing">NASCAR</abbr></dfn> sanctions many different motor races

Override default title on <dfn> when expanding acronyms

<dfn title="TLA"><abbr title="Three Letter Acronym">TLA</abbr></dfn> stands for "Three Letter Acronym"

or, look up the acronym in the Acronym Finder at Acronyms .net and just copy-and-paste the code

Prev: Misc. Next: Namespaces 

Home > HTML Cheat Sheet for Transition to HTML 5 > Tags & Attributes

Viewing mobile website page. Switch to WML or Full HTML