HTML5 has been out for a long time. However, since I am not a front-end person, I only know about this thing, and the specific concept is a bit vague (actually it is a series of standards); therefore, last year, I made a simple summary of HTML5. I just happened to see it today, so I organized it and put it on my blog to avoid losing it. Please correct me if there are any mistakes, I am a front-end noob.
Let’s start with a table of contents, as follows:
•What is HTML5
•HTML5 development history
•HTML5 detailed introduction
•Video/Audio, Canvas & SVG, Editable Content & Drag and Drop, Web Storage, Web Workers, Server Sent Events, Form Enhancements, Semantic Markup, and More HTML5 Standards
• HTML5 Example Analysis
•Flying Bird
•Bar Chart
•HTML5 Development Outlook
•Reference Resources
What is HTML5
Simply put, HTML5 is the general term for a series of related technologies used to develop modern rich Web content.
HTML5 ≈ HTML5 core specification + CSS 3 + JavaScript; HTML5 and CSS are mainly responsible for the interface, and JavaScript is responsible for logical processing;
Purpose: Reduce the dependence of Rich Internet Applications (RIA) on Flash, Silverpght, Java Applet, etc., and provide more APIs that can effectively enhance network applications.
The following picture is a typical RIA (Rich Internet Apppcations) web page, including some charts, videos, games, etc.:
##HTML5 Development History
In 2004, WHATWG (Web Hypertext Technology Working Group) proposed a draft Web Apppcations 1.0, the predecessor of HTML5;
In 2007, W3C agreed to adopt HTML5 as a standard. And established a new HTML working team;
On October 28, 2014, W3C officially released the HTML5.0 recommended standard;
Before the end of 2016, it plans to release HTML 5.1;
In the future, after HTML5.1 is announced, the working group will repeat the steps of HTML5.1 and create a new HTML5.2 to continue to improve and enrich functions.
The following table shows the evolution of the HTML 5 standard:
2012 |
2013 |
2014 |
2015 |
2016 |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Candidate Version |
Solicitation Evaluation |
Recommended standards |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
First Working Draft |
|
Final Call |
Candidate Version |
Recommended Standard |
##HTML 5.2 |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
Tips: <video width="320" height="240" controls="controls"> <source src="/i/movie.ogg" type="video/ogg"> <source src="/i/movie.mp4" type="video/mp4"> Your browser does not support the video tag. </video> Copy after login XML/HTML Code Copy content to clipboard <audio controls="controls"> <source src="/i/song.ogg" type="audio/ogg"> <source src="/i/song.mp3" type="audio/mpeg"> Your browser does not support the audio element. </audio> Copy after login is as follows, for the effect of video and audio Figure: <canvas id="myCanvas" width="200" height="100" style="border:1px sopd #c3c3c3;"> Your browser does not support the canvas element. </canvas> <script type="text/javascript"> var c=document.getElementById("myCanvas"); var ccxt=c.getContext("2d"); cxt.moveTo(10,10); cxt.pneTo(150,50); cxt.pneTo(10,50); cxt.stroke(); </script> Copy after login is as follows, the rendering: <svg xmlns="http://www.w3.org/2000/svg" version="1.1" height="190"> <polygon points="100,10 40,180 190,60 10,60 160,180" style="fill:red;stroke:blue;stroke-width:3;fill-rule:evenodd;" /> </svg> Copy after login
<script type="text/javascript"> function allowDrop(ev) { ev.preventDefault(); } function drag(ev) { ev.dataTransfer.setData("Text",ev.target.id); } function drop(ev) { ev.preventDefault(); var data=ev.dataTransfer.getData("Text"); ev.target.appendChild(document.getElementById(data)); } </script> </head> <body> <p id="p1" ondrop="drop(event)" ondragover="allowDrop(event)"> <img src="/i/w3school_logo_black.gif" draggable="true" ondragstart="drag(event)" id="drag1" /> </p> <p id="p2" ondrop="drop(event)" ondragover="allowDrop(event)"></p> Copy after login
<script type="text/javascript"> localStorage.lastname="Smith"; document.write("Last name: " + localStorage.lastname); </script> Copy after login sessionStorage <script type="text/javascript"> sessionStorage.lastname="Smith"; document.write(sessionStorage.lastname); </script> Copy after login Tips: <script> var w; function startWorker() { if (typeof (Worker) !== "undefined") { if (typeof (w) == "undefined") { w = new Worker("rs/demo_workers.js"); } w.onmessage = function(event) { document.getElementById("result").innerHTML = event.data; }; } else { document.getElementById("result").innerHTML = "Sorry, your browser does not support Web Workers..."; } } function stopWorker() { w.terminate(); } </script> Copy after login demo_workers.js文件,其中的postMessage() 方法 ,用于向 HTML 页面传回一段消息。 var i=0; function timedCount() { i=i+1; postMessage(i); setTimeout("timedCount()",500); } timedCount(); Copy after login Tips: pubpc class SSE extends ActionSupport { private InputStream sseStream; pubpc InputStream getSseStream() { return sseStream; } pubpc String handleSSE() { System.out.println("Inside handleSSE() "); String result = "data: "+new Date().toString() + "\n\n"; sseStream = new ByteArrayInputStream(result.getBytes() ); System.out.println("Exiting handleSSE() "); return SUCCESS; } } Copy after login JavaScript Code复制内容到剪贴板 <action name="handleSSE" class="pichen.java.html5.test.SSE" method="handleSSE"> <result name="success" type="stream"> <param name="contentType">text/event-stream</param> <param name="inputName">sseStream</param> </result> </action> Copy after login 客户端代码: <p><output id="result">OUTPUT VALUE</output></p> <script> (function(global, window, document) { 'use strict'; function main() { window.addEventpstener('DOMContentLoaded', contentLoaded); } function contentLoaded() { var result = document.getElementById('result'); var stream = new EventSource('handleSSE.action'); stream.onmessage=function(event){ var data = event.data+" by onmessage"; result.value = data; } } main(); })(this, window, window.document); </script> Copy after login HTML 5 表单增强功能
HTML5 Semantic Tags |