We must deal with changing standards. It’s part of our job.
HTML5 and CSS offer some amazing ways for you to improve not only the look of your site, but also its accessibility and usability.
HTML5 brings these features, which I feel are the most important out of the whole specification.
CSS3 has ways to help you style things better without resorting to Javascript
Accessibility really means usable by anyone. We tend to focus on things like
Blind and low vision users are the ones who are obviously affected, and the hearing impaired have trouble with videos without captions. The physically impaired may have trouble working mice, and cognitive impairments can be anything from reading comprehension to dyslexia, which means you need to make wise choices about your fonts and spacing.
search engines, mobile devices, slow computers, and people without javascript
Who knows what this means? Build it simple, build it to work for the lowest common denominator first, add the icing.
Web apps without js are still cake. They may not be as awesome as cake without frosting, but they can still be quite tasty if done right.
That’s a fine line.What we really mean is that your stuff should WORK everywhere. Add the whiz-bang JavaScript at the END, not from the start.
There’s not a single image on this page.
but look, the content (most important part) is readable without any images.
.You can build rich interfaces with HTML5.
We’ve been stuck using the same tags forever. It’s time for some new ones.
Overuse of Divs. Terrible disease, very contagious. You can get it from sharing code with friends or strangers. Watch out.
To keep this straight we need to add comments in our code! And the only reason we have all of those divs is to make sure we have style handles.
We can use less, and more meaningful, code to express our content. Sections, headings, and articles are perfect for what we need to do. We don’t need classes to tell us that things are posts.... a “post” is an article inside of the posts section!
Browsers don’t actually throw up if they don’t understand an element, but you can’t style them with CSS unless you declare them. So we use JS.
Once you understand how browsers can recognize these new elements, adding this library to your code should be your next step.
Ever have a need to embed data into your pages that you need to access with JS?
Makes it easy to see the size of the window too!
We can use that data to generate the popups. No more onClicks
How about a less contrived example?
Here’s a regular form that will do a regular post. What if we wanted this to be a form that posted with AJAX instead? Notice the data-remote attribute?
use jquery to find all of those data-remote forms and turn them into AJAX requests.
We can build better forms
We have some wonderful new input types in HTML5
Using the email field makes iphones happy,
Using the URL field makes URL entry happy.
Using number controls have some neat advantages too.
You can use sliders too.
There are date pickers too. Only Opera implements this currently. Other devices are still catching up.
Right now. Change your apps. Use these fields right now. IE doesn’t support them right away, but they’ll just be text fields.
We can find elements by their attributes with CSS3, and use jQuery to bolt on the datepicker easily.
No need for extra classes on form fields in most cases. Use the css3 attribute selector, supported by jQuery and other libraries.
Modernizr is great for adding detection, not support, for HTML5 features. Just make sure you understand the code.
Placeholder text can sometimes be helpful to your users if you use it as example text.
Too much code to show thanks to IE. You cannot change a password file into a text field in IE. There are plugins available to do this work for you, and another alternative is to place the placeholder text to the right of the input field as “example” text.
Autofocus places the cursor in the text field you specify.
Pretty much the same detection here. And you know how to focus on a field with jQuery now. $(“field”).focus();
HTML5 has native video support. The browser treats video like images now.
Video support is basic.
Up till now there’s been a fight about which to support.
Adobe’s flash player will play WebM.
But Apple won’t. They’ll stick with H264
So at this point in time, it’s looking like H264 or Flash, and many people encode videos in Flash using H264.
Google wanted HTML5 video for youtube and other properties. But it’s all in H264 now because Apple wants it that way.
Controversial topic
They did it with VHS, they did it with Windows Media, they made Flash the standard for video delivery.
They want “personal devices” to view adult content and that means they need H264 video.
Flash fallback, mobile support, lots of goodness. Best solution out there now, but requires multiple encodes of videos.
So this should be easier, right?
Encode audio twice, offer a download.
We have the same problem with codecs when it comes to audio.
HTML5 video and audio have a rich Javascript API. Eventually you’ll be able to trigger sounds and manipulate video very easily.
So we have some content in a DIV....
You get equal-width columns. So you’re just spliting the content, you’re not making a “main” and “sidebar” column with this. We’re talking newspapers here.
Use less markup to style things!
Conditional comments and this will give you all the stuff you need in IE.
Rounding requires all of the browser prefixes. You can round text fields too which can look quite nice.
Shadows on text is going to be the new Blink tag. They’re also hard to read and you should watch your use of this technique.
You can add shadows to boxes too.
Put those URLs in parenthesis after each link in the printed version of your page. Very handy!
All the sub elements are editable too! You can have change or blur events attached and you just persist the changes to the backend using AJAX.
You’ll need an action to submit your edits to anyway.
We can easily set and get items using the simple API.
A fallback solution is easy to create with only about 30 lines of JS or one of the various plugins available. Just remember that these are cookie-based.
Localstorage persists in a local key/value store in your browser. It’s relatively secure, and the main key is the domain you’re browsing. LocalStorage stuff never leaves your browser either, unlike cookies.
Webkit browsers have the support!
We can easily select records, and we get transaction support too!
iOs, android, chrome, safari
Firefox wants their own technology, IndexedDB, to take off. It’s a NoSQL solution, like localstorage on steroids.
So it’s nice to be able to store things client side, but why would we want to do that?
If we were making offline mobile applications.
We make a manifest file, and then link to it. Everything we need offline gets listed in the manifest
No long submission processes, just put it out there and go!
As long as we’re talking mobile,
We can detect the device width and apply different stylesheet rules based on the query.
Push content to your users!
Long polling, refreshing constantly, ajax, etc
True socket connections
This server is written in Ruby using EventMachine. NodeJS works just as well, and is about the same size in code.
The API for websockets is dead simple. Just a few events. Connect, message, close.
Flash has had support for sockets for a long time and we can use that to support old browsers.
Accessible rich internet apps
Help the blind by telling them about it.
Screenreaders see the polite region and know that not only does it update, but that updates shouldn’t interrupt the reader when it’s reading other areas.
We can help screenreaders find areas of the page with important content.
Really handy way to help screenreader users find elements. “Documents” are static documents we read. Screenreaders have shortcut keys for navigating. “Application” role tells screenreaders to turn off the shortcut keys so that the apps can use those shortcut keys instead.
Ok, so here are the things I think you should do right now, when you leave this room, start implementing these things today:
This site will let you try HTML5 and CSS3 things right in your browser.
I hear this book is pretty good. It’s available now as a PDF and will be in bookstores in December.