We must deal with changing standards. It&#x2019;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.
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.
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.
There&#x2019;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&#x2019;ve been stuck using the same tags forever. It&#x2019;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&#x2019;t need classes to tell us that things are posts.... a &#x201C;post&#x201D; is an article inside of the posts section!
Browsers don&#x2019;t actually throw up if they don&#x2019;t understand an element, but you can&#x2019;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&#x2019;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&#x2019;t support them right away, but they&#x2019;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 &#x201C;example&#x201D; 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. $(&#x201C;field&#x201D;).focus();
HTML5 has native video support. The browser treats video like images now.
Video support is basic.
Up till now there&#x2019;s been a fight about which to support.
Adobe&#x2019;s flash player will play WebM.
But Apple won&#x2019;t. They&#x2019;ll stick with H264
So at this point in time, it&#x2019;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&#x2019;s all in H264 now because Apple wants it that way.
They did it with VHS, they did it with Windows Media, they made Flash the standard for video delivery.
They want &#x201C;personal devices&#x201D; 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.
So we have some content in a DIV....
You get equal-width columns. So you&#x2019;re just spliting the content, you&#x2019;re not making a &#x201C;main&#x201D; and &#x201C;sidebar&#x201D; column with this. We&#x2019;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&#x2019;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&#x2019;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&#x2019;s relatively secure, and the main key is the domain you&#x2019;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&#x2019;s a NoSQL solution, like localstorage on steroids.
So it&#x2019;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&#x2019;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&#x2019;t interrupt the reader when it&#x2019;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. &#x201C;Documents&#x201D; are static documents we read. Screenreaders have shortcut keys for navigating. &#x201C;Application&#x201D; 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&#x2019;s available now as a PDF and will be in bookstores in December.