- HTML5 DOCTYPE
- Page Encoding
- HTML5 Markup
- New And Updated Elements
- Structural Elements
- New Attributes
- Deprecated Elements And Attributes
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8 " /> <title>XHTML1 Strict Document</title> <script type="text/javascript" src="boo.js"></script> <link type="text/css" rel="stylesheet" href="a.css"/> </head> <body> </body> </html>
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>HTML5 Document</title> <script src="boo.js"></script> <link rel="stylesheet" href="a.css"/> </head> <body> </body> </html>
<!DOCTYPE html> <meta charset=UTF-8> <title>Document Intentionally Blanks</title>
<!DOCTYPE html> <title>Tweetable Docoument</title> <p>Tweetable HTML5</p>
<hgroup> <h1>This is my header</h1> <h2>This is my subtitle</h2> <hgroup>
<figure> <img src="htmlcss1.png" alt="HTML5 & CSS3 for the Real World"/> <figcaption> My Book </figcaption> </figure>
<details> <summary>5 of 5 stars from three reviews</summary> <ul> <li>5 stars from Amazon</li> <li>5 stars from Costco</li> <li>5 stars from Barns & Noble</li> </ul> </details>
Not yet supported in FF or IE.
<dialog> This is a dialog box! <button id="closemodal">Close</button> </dialog>
var dialog = document.querySelector('dialog'); document.querySelector('#show').addEventListener('click', function() { dialog.showModal(); // dialog.show(); }); document.querySelector('#close').addEventListener('click', function() { dialog.close(); });
<dialog open> This is a dialog box! <button id="closemodal">Close</button> </dialog>
var dialog = document.querySelector('dialog'); document.querySelector('#show').addEventListener('click', function() { // dialog.showModal(); dialog.show(); }); document.querySelector('#close').addEventListener('click', function() { dialog.close(); });
Name | Color | Sex | Temperment |
---|---|---|---|
<template id="row"> <tr> <td></td> <td></td> <td></td> <td></td> </tr> </template>
<table border='1' cellpadding=5> <thead> <tr> <th>Name</th> <th>Color</th> <th>Sex</th> <th>Temperment</th> </tr> </thead> <tbody> <template id="row"> <tr> <td></td> <td></td> <td></td> <td></td> </tr> </template> </tbody> </table> <script> var data = [ { name: 'Sassafrass', color: 'Balinese', sex: 'Female', temp: 'anti-social' }, { name: 'Baby Girl', color: 'Tabby', sex: 'Female', temp: 'dog-like' }, { name: 'Katmandu', color: 'Orange Tabby', sex: 'Male', temp: 'happy' } ]; var template = document.querySelector('#row'); for (var i = 0; i < data.length; i += 1) { var cat = data[i]; var clone = template.content.cloneNode(true); var cells = clone.querySelectorAll('td'); cells[0].textContent = cat.name; cells[1].textContent = cat.color; cells[2].textContent = cat.sex; cells[3].textContent = cat.temp; template.parentNode.appendChild(clone); } </script>
var data = [ { name: 'Sassafrass', color: 'Balinese', sex: 'Female (neutered)', temp: 'anti-social' }, { name: 'Baby Girl', color: 'Tabby', sex: 'Female (neutered)', temp: 'dog-like' }, { name: 'Katmandu', color: 'Orange Tabby', sex: 'Male (neutered)', temp: 'happy' } ]; var template = document.querySelector('#row'); for (var i = 0; i < data.length; i += 1) { var cat = data[i]; var clone = template.content.cloneNode(true); var cells = clone.querySelectorAll('td'); cells[0].textContent = cat.name; cells[1].textContent = cat.color; cells[2].textContent = cat.sex; cells[3].textContent = cat.temp; template.parentNode.appendChild(clone); }
<template id="foo"> <style> /* styles scoped to template only </style> <div class="someclass"> template text here <div class="someotherclass"> <content></content> </div> </div> </template>
<template id="foo"> <style> /* styles scoped to template only </style> <div class="someclass"> template text here <div class="someotherclass"> <content select=".someSelector"></content> </div> </div> </template>
<div class="name-tag"><i class="f">Jean</i> <i class="l">Phillippe</i></div> <div class="name-tag"><i class="l">Weyl</i>, <i class="f">Estelle</i></div> <div class="name-tag"><i class="l">Smith</i>, <i class="f">Jane</i></div> <template id="nameTagTemplate"> <style> .outer { border: 2px solid brown; border-radius: 1em; background: red; font-size: 20pt; width: 12em; height: 7em; text-align: center; margin-bottom: 1em; } .boilerplate { color: white; font-family: sans-serif; padding: 0.5em; } .name { color: black; background: white; font-family: "Marker Felt", cursive; font-size: 45pt; padding-top: 0.2em; } </style> <div class="outer"> <div class="boilerplate"> Hi! My name is </div> <div class="name"> <content select=".f"></content> <content select=".l"></content> </div> </div> </template> <script> var el = document.querySelectorAll('.name-tag'); var template = document.getElementById('nameTagTemplate'); for(var i = 0; i < el.length; i++) { var shadow = el[i].createShadowRoot(); var clone = document.importNode(template.content, true); shadow.appendChild(clone); } </script>
IE6-8 does not style elements that don't exist, so create the elements!
<!--[if IE]> <script type="text/javascript"> (function(){ var html5elmeents ="article|aside|audio|canvas|...|video"; html5elmeents.split('|'); for(var i = 0; i < html5elmeents.length; i++){ document.createElement(html5elmeents[i]); } })(); </script> <![endif]-->
"Ruby" are short runs of text alongside the base text, typically used in East Asian documents to indicate pronunciation or to provide a short annotation.
display: ruby | ruby-base | ruby-text | ruby-base-container | ruby-text-container; ruby-align: auto | start | left | center | end | right | distribute-letter | distribute-space | line-edge; ruby-overhang: auto | start | end | none; ruby-position: before | after | right | inline; ruby-span: attr(x) | none;
<ruby> ♥<rp>: </rp> <rt>Heart</rt> <rp>, </rp> <rtc> <rt lang=fr>Cœur</rt> </rtc> <rp>.</rp> ☘<rp>: </rp> <rt>Shamrock</rt> <rp>, </rp> <rtc> <rt lang=fr>Trèfle</rt> </rtc> <rp>.</rp> ✶<rp>: </rp> <rt>Star</rt> <rp>, </rp> <rtc> <rt lang=fr>Étoile</rt> </rtc> <rp>.</rp> </ruby>
If ruby is supported:
♥ ☘ ✶If not:
<p tabindex="-1">Focusable with Javascript</p>
<pre contenteditable>Look. I am editable>/pre>
I am editable
This paragrph has an error.
spellcheck="true | false"Since IE 10
Define your own DOM manipulable data attributes
<div id="card27" data-cardID="27" data-row="3" data-col="2"></div>
var info = document.querySelector('#card27'); var cardinfo = []; for (var key in info.dataset) { cardinfo.push(key, ': ', info.dataset[key], ','); } var currentCard = cardinfo.join('');
Result:
currentCard == 'cardID: 27, row: 3, col: 2'
var cardID = info.getAttribute('data-cardID'); //27
All browsers support "data-*", but full support of 'dataset started with IE10, FF6, Safari 5.1, Chrome 7, Opera 11.1
Google processes RDFa, Microformats and Microdata.
itemid itemprop itemref itemscope itemtype
person url nickname affiliation(org) photo friend title contact role acquaintance address(adr)
<div itemscope itemtype="http://data-vocabulary.org/Person"> <img src="estelle.gif" itemprop="photo"> <p>Name: <i itemprop="name">Estelle Weyl</i> <p>Title: <i itemprop="title">Speaker, UI Engineer</i> <p>Blog: <a href="http://standardista.com" itemprop="affliation">Standardista. <p itemprop="address" itemscope itemtype="http://data-vocabulary.org/Address">Address: <i itemprop="locality">San Carlos</i>, <i itemprop="region">CA</i></p> </div>
Options: