html5 and css3: does now really mean now?

Post on 15-May-2015

5.149 Views

Category:

Technology

3 Downloads

Preview:

Click to see full reader

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

CSS3 and HTML5

Does now reallymean now?

Saturday, 10 March 2012

‣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

Saturday, 10 March 2012

cmills@opera.com@chrisdavidmills

http://www.slideshare.net/chrisdavidmillshttp://dev.opera.com

http://www.w3.org/community/webed/

Saturday, 10 March 2012

‣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

Saturday, 10 March 2012

Do you need it at all?

Saturday, 10 March 2012

Saturday, 10 March 2012

Saturday, 10 March 2012

Saturday, 10 March 2012

Saturday, 10 March 2012

‣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

Do you need it?

Saturday, 10 March 2012

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

Progressive enhancement

Saturday, 10 March 2012

‣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

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

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

‣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

‣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

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

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

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

Acceptable alternatives

Saturday, 10 March 2012

‣<img>!

‣<canvas>/WebGL

‣<video>

‣Web sockets

‣etc.

Ok, sometimes progressive enhancement isn’t really possible

Saturday, 10 March 2012

‣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

‣Typical example of HTML5’s attitude to fallback

HTML5 <video>

Saturday, 10 March 2012

<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

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

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

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

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

Saturday, 10 March 2012

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

Saturday, 10 March 2012

Modernizr

‣The mother of all feature detection libraries

‣Available at modernizr.com

Saturday, 10 March 2012

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

Saturday, 10 March 2012

<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

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

Modernizr CSS example

Saturday, 10 March 2012

.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

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

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

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

Polyfills/shims

Saturday, 10 March 2012

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

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

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

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

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

‣http://excanvas.sourceforge.net/

‣Add <canvas> support to IE

Excanvas

Saturday, 10 March 2012

‣http://selectivizr.com/

‣Adds support for CSS3 selectors to IE6-8

Selectivizr

Saturday, 10 March 2012

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

To summarise

Saturday, 10 March 2012

Does now really mean now?

Saturday, 10 March 2012

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

‣Are great

‣But complicate things

‣And give a performance hit

Polyfills

Saturday, 10 March 2012

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

It will be a while before things get easier

Saturday, 10 March 2012

More resources

‣html5please.com

‣caniuse.com

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

Saturday, 10 March 2012

cmills@opera.com@chrisdavidmills

http://www.slideshare.net/chrisdavidmillshttp://dev.opera.com

http://www.w3.org/community/webed/

Thanks!

Saturday, 10 March 2012

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

top related