html5 and css3: does now really mean now?

60
CSS3 and HTML5 Does now really mean now? Saturday, 10 March 2012

Upload: chris-mills

Post on 15-May-2015

5.149 views

Category:

Technology


3 download

DESCRIPTION

Code at http://people.opera.com/cmills/css3book/css3-html5-dnrmn.zip. The browser vendors love them! The browser fans and cutting edge designers are producing some really remarkable stuff, but what do HTML5 and CSS3 really mean for you, the pragmatic designer on the street? If you sidle up to one of those guys and whisper "but what about IE6 support", they are likely to slap you in the face, or run away with their hands clamped over their ears, yelling "la lala lala, I can't hear you." In this talk, Chris Mills will have a look at some of the new features of HTML5 and CSS3 - new semantics, video, media queries, rounded corners, web fonts, drop shadows and more. He will show real world examples, and then look at how they actually perform on those shady older browsers we are often called on to support. He will then look at strategies for providing support for those older browsers, including using JavaScript, fallbacks, and progressive enhancement.

TRANSCRIPT

Page 1: HTML5 and CSS3: does now really mean now?

CSS3 and HTML5

Does now reallymean now?

Saturday, 10 March 2012

Page 2: HTML5 and CSS3: does now really mean now?

‣Open standards advocate and education agitator

‣dev.opera.com editor

‣W3C web education community group chair

‣Accessibility whiner

‣HTML5/CSS3 wrangler

‣Heavy metal drummer & proud dad

Hi! I’m Chris Mills

Saturday, 10 March 2012

Page 3: HTML5 and CSS3: does now really mean now?

Saturday, 10 March 2012

Page 5: HTML5 and CSS3: does now really mean now?

‣Do you really need The Shiny™?

‣Progressively enhance, don’t rely on it

‣When progressive enhancement isn’t viable, provide alternatives, use feature detection...

‣...use polyfills/shims

‣#sxsw #dnrmn (lol, lmao, wtf, etc.)

What we’ll talk about

Saturday, 10 March 2012

Page 6: HTML5 and CSS3: does now really mean now?

Saturday, 10 March 2012

Page 7: HTML5 and CSS3: does now really mean now?

Do you need it at all?

Saturday, 10 March 2012

Page 8: HTML5 and CSS3: does now really mean now?

Saturday, 10 March 2012

Page 9: HTML5 and CSS3: does now really mean now?

Saturday, 10 March 2012

Page 10: HTML5 and CSS3: does now really mean now?

Saturday, 10 March 2012

Page 11: HTML5 and CSS3: does now really mean now?

Saturday, 10 March 2012

Page 12: HTML5 and CSS3: does now really mean now?

‣But just because you can use them doesn’t mean you have to use them. All the bloody time!

‣In the real world, with real clients, you are likely to have less freedom

HTML5 and CSS3 are fun

Saturday, 10 March 2012

Page 13: HTML5 and CSS3: does now really mean now?

Do you need it?

Saturday, 10 March 2012

Page 14: HTML5 and CSS3: does now really mean now?

If you are going to useprefixed CSS/JS...

background: -webkit-linear-gradient(#ff0000, #000000);background: -moz-linear-gradient(#ff0000, #000000);background: -ms-linear-gradient(#ff0000, #000000);background: -o-linear-gradient(#ff0000, #000000);background: linear-gradient(#ff0000, #000000);

Saturday, 10 March 2012

Page 15: HTML5 and CSS3: does now really mean now?

Progressive enhancement

Saturday, 10 March 2012

Page 16: HTML5 and CSS3: does now really mean now?

‣If *at all possible*

‣Build a base level of functionality that works

‣Then enhance the user experience

Don’t rely on The Shiny™

Saturday, 10 March 2012

Page 17: HTML5 and CSS3: does now really mean now?

Example: Ajax

‣Ajax makes data updates more responsive

‣But the base functionality could still work with no Ajax

‣Albeit with page reloads

Saturday, 10 March 2012

Page 19: HTML5 and CSS3: does now really mean now?

Example: CSS3 bling

‣Content looks a lot nicer in supporting browsers

‣Also more flexible than using old graphical methods

‣But the content should still be accessible in older browsers

‣http://www.alistapart.com/articles/css3-bling-in-the-real-world/

Saturday, 10 March 2012

Page 20: HTML5 and CSS3: does now really mean now?

‣If done properly, a lot of CSS animations and transitions can be used unobtrusively

‣For example, by default the element is set to be in its usable state, but then the animation is applied over the top to bring the animation to that state

Example: CSS animation

Saturday, 10 March 2012

Page 21: HTML5 and CSS3: does now really mean now?

‣One of the obvious ones!

‣If media queries are not supported, the browser ignores them, and you get the standard layout

‣Of course, this can be a problem if you are using the “mobile first” approach

Example: Media queries

Saturday, 10 March 2012

Page 22: HTML5 and CSS3: does now really mean now?

Example: Web fonts

‣This is a perfect feature to use now!

‣IE has supported EOT since IE4/5!

‣You can use the bulletproof web font syntax - see fontsquirrel.com

Saturday, 10 March 2012

Page 23: HTML5 and CSS3: does now really mean now?

This is all fine...

‣So long as your boss/client is cool with that!

‣Many still obsess over identical layouts/functionality across browsers

Saturday, 10 March 2012

Page 24: HTML5 and CSS3: does now really mean now?

Identical layout/functionality obsession

‣A thing of the past?

‣It is becoming much less of an issue, with so many different browsing platforms and devices now available

‣Many different contexts require different layouts/functionality for a good user experience

Saturday, 10 March 2012

Page 25: HTML5 and CSS3: does now really mean now?

Acceptable alternatives

Saturday, 10 March 2012

Page 26: HTML5 and CSS3: does now really mean now?

‣<img>!

‣<canvas>/WebGL

‣<video>

‣Web sockets

‣etc.

Ok, sometimes progressive enhancement isn’t really possible

Saturday, 10 March 2012

Page 27: HTML5 and CSS3: does now really mean now?

‣Equivalence of service

‣Useful for multiple user groups

‣As long as they can access the content and services in some way, you should be ok

Fallbacks often a good option

Saturday, 10 March 2012

Page 28: HTML5 and CSS3: does now really mean now?

‣Typical example of HTML5’s attitude to fallback

HTML5 <video>

Saturday, 10 March 2012

Page 29: HTML5 and CSS3: does now really mean now?

<video controls> <source src="video-file.mp4" type="video/mp4"> <source src="video-file.webm" type="video/webm"> <track src="en.vtt" kind="subtitles" srclang="en" label="English subtitles"> <!-- Flash player often referenced in here: will play the MP4 version of the video --></video>

HTML5 <video>

Saturday, 10 March 2012

Page 30: HTML5 and CSS3: does now really mean now?

Flash fallbacks viable

‣Might seem annoying to have to implement, but once you’ve got a template, you’re off.

‣And Flash can just load the MP4 version of the video

‣Also consider jPlayer, Sublime, etc.

Saturday, 10 March 2012

Page 31: HTML5 and CSS3: does now really mean now?

Unfortunately...

‣The fallback content is for browsers that don’t support <video>

‣Not for browsers that don’t support the format being offered up

‣You’ll need multiple formats for the time being

Saturday, 10 March 2012

Page 32: HTML5 and CSS3: does now really mean now?

What about when alternative mechanisms don’t exist?

‣Make your own!

‣Use feature detection

‣Basic tests, or a library like Modernizr

Saturday, 10 March 2012

Page 33: HTML5 and CSS3: does now really mean now?

Feature detection basicsif (window.chrome) { // do stuff that works on Chrome}else { // ignore it, and do something else}

Saturday, 10 March 2012

Page 34: HTML5 and CSS3: does now really mean now?

Feature detection basicsif (checkVideo()===true) { // do stuff that uses this method}else { // ignore it, and do something else}

Saturday, 10 March 2012

Page 35: HTML5 and CSS3: does now really mean now?

Modernizr

‣The mother of all feature detection libraries

‣Available at modernizr.com

Saturday, 10 March 2012

Page 36: HTML5 and CSS3: does now really mean now?

Modernizr CSS example<html lang="en-US" class="no-js"><head> ...<script src="modernizr.js"></script> ...</head>

Saturday, 10 March 2012

Page 37: HTML5 and CSS3: does now really mean now?

<html class=" js flexbox canvas canvastext webgl no-touch geolocation postmessage no-websqldatabase indexeddb hashchange history draganddrop websockets rgba hsla multiplebgs backgroundsize borderimage borderradius boxshadow textshadow opacity cssanimations csscolumns cssgradients no-cssreflections csstransforms no-csstransforms3d csstransitions fontface generatedcontent video audio localstorage no-sessionstorage webworkers applicationcache svg inlinesvg smil svgclippaths" lang="en-US">

Modernizr CSS example

Saturday, 10 March 2012

Page 38: HTML5 and CSS3: does now really mean now?

#wrapper:hover, #wrapper:focus { transform: rotateX(180deg);}

Modernizr CSS example

Saturday, 10 March 2012

Page 39: HTML5 and CSS3: does now really mean now?

.no-csstransforms3d #wrapper #front { transition: 0.8s all ease-in;}

.no-csstransforms3d #wrapper:hover #front,

.no-csstransforms3d #wrapper:focus #front { transform: rotate(-30deg) translate(-50%,-100%);}

Modernizr CSS example

Saturday, 10 March 2012

Page 40: HTML5 and CSS3: does now really mean now?

function rotateForm() { if(Modernizr.cssanimations) { form.setAttribute("class","form-rotate"); form.style.left = "0rem"; } else { back.style.zIndex = "5"; }; };

Modernizr JS example

Saturday, 10 March 2012

Page 41: HTML5 and CSS3: does now really mean now?

In general, Modernizr rocks

‣It can add a fair bit of weight to your page: 49KB for the full library

‣But you can create a smaller custom version that just includes the tests you need

‣There are some things that can’t be detected

Saturday, 10 March 2012

Page 42: HTML5 and CSS3: does now really mean now?

IE conditional comments<!--[if lte IE 8]> <link rel="stylesheet" href="iefixes.css" type="text/css"><![endif]--><!--[if lte IE 6]> <link rel="stylesheet" href="ie6.css" type="text/css"> <![endif]-->

Saturday, 10 March 2012

Page 43: HTML5 and CSS3: does now really mean now?

Polyfills/shims

Saturday, 10 March 2012

Page 44: HTML5 and CSS3: does now really mean now?

Add in support where needed

‣Using JavaScript

‣Fake SVG in old IE versions using VML

‣Fake box-shadow using IE filters (although they are evil — every time you use IE filters, god kills a kitten)

Saturday, 10 March 2012

Page 45: HTML5 and CSS3: does now really mean now?

Adding HTML5 support to browsers

‣Older browsers don’t support them!

‣But you can style any unknown element, so just set all the “block level” elements to display as block, at the top of your CSS:

‣article { display: block; }

Saturday, 10 March 2012

Page 46: HTML5 and CSS3: does now really mean now?

Oh, but IE 6-8 needsome more help

‣They refuse to style unknown elements, unless you create instances of them in the DOM

‣document.createElement('article');

Saturday, 10 March 2012

Page 47: HTML5 and CSS3: does now really mean now?

CSS3 PIE for CSS bling support

‣http://css3pie.com/

‣Awesome little library

‣Add support to IE6-8 for box-shadow, border-radius, gradients and transparent colours

‣But not text-shadow, which is a little frustrating

Saturday, 10 March 2012

Page 48: HTML5 and CSS3: does now really mean now?

CSS3-mediaqueries.js

‣http://code.google.com/p/css3-mediaqueries-js/

‣Add media queries support to IE

‣A bit clunky, when you resize, but it works

Saturday, 10 March 2012

Page 49: HTML5 and CSS3: does now really mean now?

‣http://excanvas.sourceforge.net/

‣Add <canvas> support to IE

Excanvas

Saturday, 10 March 2012

Page 50: HTML5 and CSS3: does now really mean now?

‣http://selectivizr.com/

‣Adds support for CSS3 selectors to IE6-8

Selectivizr

Saturday, 10 March 2012

Page 51: HTML5 and CSS3: does now really mean now?

All sounds good, huh?

‣Beware: slows down loading!

‣Especially stuff that makes use of IE filters

‣Can be mitigated by helpers such as YepNope

Saturday, 10 March 2012

Page 52: HTML5 and CSS3: does now really mean now?

To summarise

Saturday, 10 March 2012

Page 53: HTML5 and CSS3: does now really mean now?

Does now really mean now?

Saturday, 10 March 2012

Page 54: HTML5 and CSS3: does now really mean now?

Progressive enhancement and alternatives

‣Can be successful

‣But not everything is easy to provide for

‣And your clients might not approve

Saturday, 10 March 2012

Page 55: HTML5 and CSS3: does now really mean now?

‣Are great

‣But complicate things

‣And give a performance hit

Polyfills

Saturday, 10 March 2012

Page 56: HTML5 and CSS3: does now really mean now?

Think carefully

‣Do you need to do it this way?

‣Is there viable alternative content that can be provided, or different ways to implement it?

Saturday, 10 March 2012

Page 57: HTML5 and CSS3: does now really mean now?

It will be a while before things get easier

Saturday, 10 March 2012

Page 58: HTML5 and CSS3: does now really mean now?

More resources

‣html5please.com

‣caniuse.com

‣Practical CSS3: design and develop (Peachpit Press, August 2012ish)

Saturday, 10 March 2012

Page 60: HTML5 and CSS3: does now really mean now?

Spidermen — http://www.flickr.com/photos/ralphman/792848885/

Schoolkids — http://www.flickr.com/photos/mallalamuseum/3838470381/

Old married couple — http://www.flickr.com/photos/adwriter/257937032/

No IE6 — http://www.navegabem.com

Parrot — http://www.flickr.com/photos/young-in-panama/57895100/

Immortal — 10 most ridiculous black metal photos ever

Thank you CC!

Saturday, 10 March 2012