I gave this presentation at the 2010 Scotch on the Rocks conference. It features a brief explanation of why HTML5 and CSS3 are necessary, and then goes on to cover most of the cool new features of HTML5 and CSS3 that are supported across most browsers at the time of publication., including <video>, <canvas>, HTML5 forms, the new HTML5 elements, box-shadow, text-shadow, web fonts, media queries, and more. Companion code examples are available at http://people.opera.com/cmills/HTML5_CSS3_examples.zip
9. HTML5 and CSS3 aren't
replacements
They are backwards compatible
They fill up gaps
They add new features on top of the
old specs
10. They, um, compete with plugins
Ian Hickson has already said as
much.
HTML5 will directly compete with
other web application technologies,
like Flash and Silverlight
11. HTML5 features
More accurate semantics (eg
<header>, <footer>)
Better forms (built in validation!)
<video>
<canvas>
16. Deeper into the page...
<article>
<header>
<h1>Article about Chris Mills</h1>
</header>
<p>Article text...</p>
<figure>
<img src=chris.jpg alt=”Chris Mills”>
<figcaption>Chris Mills</figcaption>
</figure>
<footer>
<p>Published <time datetime=2010-05-06
pubdate>May 6th 2010</time></p>
</footer>
</article>
17. Better semantics?
Document parts now have clear
meaning
More machine readable
Arguably easier for AT to read
Easier to write
Easier to target with CSS and JS
18. When can we use these?
Now.
Browsers don't do anything w/ them
But you can do display: block;
And get into the habit
Still machine-readable
19. HTML5 forms
Previously called “Web forms 2.0”
More powerful form elements
Built-in validation
More standard archetypes
26. function validate() {
var str = "";
var elements = document.getElementsByTagName('input');
// loop through all input elements in form
for(var i = 0; i < elements.length; i++) {
// check if element is mandatory; ie has a pattern
var pattern = elements.item(i).getAttribute('pattern');
if (pattern != null) {
var value = elements.item(i).value;
// validate the value of this element, using its defined pattern
var offendingChar = value.match(pattern);
// if an invalid character is found or the element was left emtpy
if(offendingChar != null || value.length == 0) {
// add up all error messages
str += elements.item(i).getAttribute('errorMsg') + "n" +
"Found this illegal value: '" + offendingChar + "' n";
// notify user by changing background color, in this case to red
elements.item(i).style.background = "red";
}
}
}
if (str != "") {
// do not submit the form
alert("ERROR ALERT!!n" +str);
return false;
} else {
// form values are valid; submit
return true;
}
}
33. HTML5 <video> (& <audio>)
New tags, plus new API for
controlling audio and video!
34. The old school way
<object width="425" height="344">
<param name="movie"
value="http://www.example.com/v/LtfQg4KkR88&h
l=en&fs=1"></param>
<param name="allowFullScreen"
value="true"></param>
<embed
src="http://www.example.com/v/LtfQg4KkR88&hl=
en&fs=1"
type="application/x-shockwave-flash"
allowfullscreen="true" width="425"
height="344"></embed>
</object>
35. The trouser-tinglingly sexy new
way
<video src="video.webm"
controls
autoplay
loop
poster="poster.jpg"
preload=”none”
width="320" height="240">
<a href="video.webm">Download movie</a>
</video>
36. Native <video> is awesome
Works well with open standards
Built-in keyboard accessibility
API for customising controls, etc.
DOESN'T require plugins
40. <video> captions
function timeupdate() {
var v = document.querySelector('video');
var now = v.currentTime; …
}
<video width=600 src=synergy.ogv
ontimeupdate=timeupdate()>
<p>
<span data-begin=1 data-end=2.4>Hello,
Good Evening</span>
<span data-begin=3 data-end=3.6> and
Welcome.</span>
</p>
41. CSS3...
Will save you a lot of time
previously spent in Photoshop
Allows you to create the same tacky
shit...
64. Include the font
@font-face {
font-family: "My font";
src: url("http://www.myweb.com/fonts/
myfont.ttf")
format("truetype");
}
65. Use it in your page as normal
p { font-family: "My font"; }
66. Web Fonts issues
Good free fonts are available, but...
Many are not licensed for the Web
Some also mean large downloads
Some solutions are being explored
67. Media queries
You know what media types are
Media queries take the idea further
Apply CSS depending on device
attributes