730 likes | 858 Views
PCRE PHP WEBTECHNOLOGY MYSQL WEB2.0. HTML5 (& CSS3 & …). hi, I am Rogier van der Linde. I like deserts…. …HDR photography…. …and web technology. I work @ KAHO St Lieven…. …in Gent, Belgium . GENT 10 DAYS SUMMER FESTIVAL. Say hello to HTML5. Buzzwords.
E N D
PCREPHPWEBTECHNOLOGYMYSQLWEB2.0 HTML5 (& CSS3 & …)
Buzzwords • Some buzzwords:- browser- webGL 3D graphics- web sockets- <canvas>- <audio>- local Storage • More buzzwords:- CSS3- web SQL database- application Cache- …
Browsers • Classic applications are dead (sort of)
Browsers • Plugins are dead (sort of)
Web standards status • Under development: standard is under construction-> CSS3 • Working draft: standard is published for review by "the community"; major changes expected-> HTML 5, XHTML 2 • Candidate recommendation: feedback from implementors; minor changes possible, usually for practical reasons-> CSS 2.1 • Proposed recommendation: document is submitted to the W3C council for final approvement • W3C Recommendation: standard is accepted by the W3C for wide deployment-> HTML 4, XHTML 1.1, CSS 2…
Web standards support • Forget about 'support' for a whole browser or standard • Focus on features you can use today • Provide graceful degradation for partially supported features (example: rounded corners)
HTML5 • HTML5 ≈ HTML + JS API + CSS
HTML – semantics • Web 2.0: - user generated content- Rich Internet Applications- connectivity (site mashups) • Web 3.0: "The Semantic Web", i.e. software should be able to understand web content • Example: http://microformats.org/wiki/calendar(install FireFox Operator plugin first)
HTML – semantics • Classical page structure: ... <body> <div id="header">...</header> <div id="nav">...</nav> <div class="article"> <div class="section"> ... </div> </div> <div id="aside">...</div> <div id="footer">...</div> </body> ...
HTML – semantics • Classical page structure:
HTML – semantics • New page structure: ... <body> <header>...</header> <nav>...</nav> <article> <section> ... </section> </article> <aside>...</aside> <footer>...</footer> </body> ...
HTML – semantics • New page structure:
HTML – semantics • More new elements (not supported yet): <menu> <progress> <mark> <meter> ...
HTML – semantics • New link relations: <link rel="alternate" type="application/rss+xml" href="http://myblog.com/feed" /> <link rel="icon" href="images/icons/favicon.ico" /> <link rel="first" href="http://myblog.com/page1.php"> <link rel="prefetch" href="http://myblog.com/main.php"> <a rel="author" href="http://myblog.com/aboutme">Rogier</a> <a rel="external" href="http://notmysite.com">tutorial</a> <a rel="next" href="http://myblog.com/page2.php"> <a rel="search" href="http://myblog.com/search">search this blog</a> <a rel="tag" href="http://myblog.com/category/games">games posts</a>
HTML – semantics • Microdata: <div itemscopeitemtype="http://example.org/band"> <p>My name is <span itemprop='name'>Neil</span>.</p> <p>My band is called <span itemprop="band">Four Parts Water</span>.</p> <p>I am <span itemprop="nationality">British</span>.</p> </div>
HTML – semantics • ARIA (Accessible Rich Internet Applications): <ul id="tree1" role="tree" tabindex="0" aria-labelledby="label_1"> <li role="treeitem" tabindex="-1" aria-expanded="true">Fruits</li> <li role="group"> <ul> <li role="treeitem" tabindex="-1">Oranges</li> <li role="treeitem" tabindex="-1">Pineapples</li> ... </ul> </li> </ul>
HTML – semantics • ARIA (Accessible Rich Internet Applications): <h2 id="limg">Paragliding</h2> <p id="dimg"> A long description of our paragliding trip ... </p> <div> <img src="takeoff.png" alt="Getting ready to take off" aria-labelledby="limg" aria-describedby="dimg"> </div>
HTML – web forms • E-mail, time, date…: <input type="number" /> <input type="email" /> <input type="time" /> <input type="date" /> <input type="datetime" /> <input type="month" /> <input type="week" /> <input type="range" min="0" max="50" value="0" /> • Color, tel (not supported yet): <input type="color" /> <input type="tel" />
HTML – web forms • Placeholder and autofocus: ... <input type="text" placeholder="Search inside" /> <input type="text" autofocus="autofocus" /> ... • Required: ... <input type="text" required="required" /> ...
HTML – web forms • Enhanced slider example: <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="nl"> <head> <title> Testpage </title> <script type="text/javascript"> window.onload = function() { document.getElementById("slider1").onchange = function() { document.getElementById("span1").innerHTML = this.value; } } </script> </head> <body> <form action="#"> <p> <label>0<input type="range" min="0" max="50" value="0" name="slider1" id="slider1" />50</label> </p> <p>Current value: <span id="span1">0</span></p> </form> </body> </html>
HTML – interaction • Datalist: <label>Enter your favorite character:</label> <input type="text" list="characters" /> <datalist id="characters"> <option value="Homer Simpson"> <option value="Bart"> <option value="Fred Flinstone"> </datalist> • Details (not supported yet): <details open="open"> <p> If your browser supports this element, it should allow you to expand and collapse these details. </p> </details>
HTML – interaction • Editable content: <h3 contenteditable>Add your title here</h3> <img src="images/photo.jpg" alt="photo"> <p contenteditable> Add your description here </p> • Draggable content: <img src="images/product1.jpg" alt="ball" draggable="true" /> <img src="images/product2.jpg" alt="animal" draggable="false" /> <img src="images/product3.jpg" alt="rope" draggable="true" /> <div id="dropzone"> ...drop item here... </div>
HTML – interaction • Drag and drop example 1 (dragging text): ... <script type="text/javascript"> window.onload = function() { var dropZone = document.querySelector('#dropzone'); dropZone.ondragenter = dropZone.ondragover = function(event) { return false; } dropZone.ondrop = function(event) { txtPassed = event.dataTransfer.getData('text/plain'); this.innerHTML = txtPassed; return false; } } </script> </head> <body> <p>Lorem dolor sit amet, consectetur adipisicing elit ...</p> <p>Duis aute irure dolor in reprehenderit in voluptate ...</p> <div id="dropzone"> ...drop item here... </div> </body></html>
HTML – interaction • Drag and drop example 2 (dragging images): ... <script type="text/javascript"> window.onload = function() { var dropZone = document.querySelector('#dropzone'); dropZone.ondragenter = dropZone.ondragover = function(event) { return false; } dropZone.ondrop = function(event) { imgPassed = event.dataTransfer.getData('text/uri-list'); this.innerHTML = "<img src='" + imgPassed + "'/>"; return false; } } </script> </head> <body> <div> <img src="images/product1.jpg" alt="ball" /> <img src="images/product2.jpg" alt="animal" draggable="false" /> <img src="images/product3.jpg" alt="rope" /> </ol> <div id="dropzone">...drop item here... </div> </body></html>
HTML – multimedia • Audio: <audio src="multimedia/paoloconte.mp3" controls width="670" style="border: solid 3px black; margin:200"> Your browser dows not support the audio tag </audio> • Video: <video src="multimedia/tango.mp4" controls poster="images/meloYBratt.jpg" width="320" height="240"> Your browser dows not support the video tag </video>
HTML – multimedia • Different media: <video poster="poster.jpg"> <source src="video.3gp" type="video/3gpp" media="handheld"> <source src="video.ogv" type="video/ogg; codecs=theora, vorbis"> <source src="video.mp4" type="video/mp4"> </video> <audio> <source src="music.oga" type="audio/ogg"> <source src="music.mp3" type="audio/mpeg"> </audio>
HTML – multimedia • Replace controls with your own (HTML): ... <body> <video src="multimedia/tango.mp4" poster="images/meloYBratt.jpg" width="320" height="240" id="video" controls="controls"> Your browser dows not support the video tag </video> <nav id="myControls"> <a href="#" id="lnkPlay">play</a> <a href="#" id="lnkMute">mute</a> <input type="range" min="0" max="211" value="0" id="inpSeek" /> </nav> </body> </html>
HTML – multimedia • Replace controls with your own (Javascript): ... <script type="text/javascript"> window.onload = function() { var video = document.getElementById("video"); video.controls = false; document.getElementById("lnkPlay").onclick = function() { if (video.paused) video.play(); else video.pause(); return false; } document.getElementById("lnkMute").onclick = function() { if (video.volume > 0) video.volume = 0; else video.volume = 1; return false; } document.getElementById("inpSeek").onchange = function() { video.currentTime = this.value; } } </script> </head> ...
HTML – 2D and 3D drawing • Canvas: ... <script> window.onload = function() { var canvasContext = document.getElementById("canvas").getContext("2d"); canvasContext.fillRect(250, 25, 150, 100); canvasContext.beginPath(); canvasContext.arc(450, 110, 100, Math.PI * 1/2, Math.PI * 3/2); canvasContext.lineWidth = 15; canvasContext.lineCap = 'round'; canvasContext.strokeStyle = 'rgba(255, 127, 0, 0.5)'; canvasContext.stroke(); } </script> </head> <body> <canvas id="canvas" width="838" height="220"></canvas> ...
HTML – 2D and 3D drawing • Canvas with WebGL (view on Chromium browser): ... <script> window.onload = function() { var gl = document.getElementById("canvas") .getContext("experimental-webgl"); gl.viewport(0, 0, canvas.width, canvas.height); ... } </script> </head> <body> <canvas id="canvas" width="838" height="220"></canvas> </body> </html>
HTML – 2D and 3D drawing • Canvas/WebGLis very new but verrrryy promising • More demo's:- http://apirocks.com/html5/html5.html#slide24 - http://www.khronos.org/webgl/wiki/Demo_Repository- http://www.ambiera.com/coppercube/webgldemos.html
HTML – SVG • Scalable Vector Graphics • XML format for graphics • Typical fragment: <svg xmlns="http://www.w3.org/2000/svg" width="467" height="462"> <rect x="80" y="60" width="250" height="250" rx="20" style="fill:#ff0000; stroke:#000000;stroke-width:2px;" /> <rect x="140" y="120" width="250" height="250" rx="40" style="fill:#0000ff; stroke:#000000; stroke-width:2px; fill-opacity:0.7;" /> </svg>
HTML – SVG • Integration with HTML highly unsupported • Other demos:- http://apirocks.com/html5/html5.html#slide26- http://apirocks.com/html5/html5.html#slide27
HTML – wrapup • Semantics (new elements, microdata, ARIA) • Web Forms (new elements and attributes) • Interaction (suggest list, editable content, drag/drop…) • Multimedia (audio and video) • 2D and 3D drawing (Canvas, WebGL, SVG)
Javascript API – new selectors • Finding elements by class: var el = document.getElementById("section1"); var els = document.getElementsByTagName("div"); var els = document.getElementsByClassName("section"); • Finding elements by CSS syntax: var els = document.querySelectorAll("ul li:nth-child(odd)"); var els = document.querySelectorAll("table.test > tr > td");