1 / 54

HTML5 and CSS3 Techniques You Can Use Today

DEV334. HTML5 and CSS3 Techniques You Can Use Today. Todd Anglin Chief Evangelist Telerik. Introductions. Todd Anglin Chief Evangelist, Telerik Microsoft MVP ASP Insider President NHDNUG & O’Reilly Author. TelerikWatch.com. @ toddanglin. Session Road Map.

galeno
Download Presentation

HTML5 and CSS3 Techniques You Can Use Today

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. DEV334 HTML5 and CSS3 Techniques You Can Use Today Todd Anglin Chief Evangelist Telerik

  2. Introductions Todd Anglin Chief Evangelist, Telerik Microsoft MVP ASP Insider President NHDNUG & O’Reilly Author TelerikWatch.com @toddanglin

  3. Session Road Map Goal: Leave with at least 1 HTML5/CSS3 technique you can use today

  4. While it continues to serve as a rough guide to many of the core features of HTML, it does not provide enough information to build implementations that interoperate with each other and, more importantly, with a critical mass of deployed content.” -W3C on HTML4

  5. HTML4 = Rough Guide Unpredictable Browser Support

  6. How is the web evolving?

  7. { } <HTML> CSS:3; EMCAScript(); “HTML5”

  8. “Living Standard” Offline Canvas Video Audio WebSocketsFileAPI WebGL HTML5 Forms Geolocation WHATWG | W3C | IETF

  9. Stable Canvas | Local Storage |Microdata| Document Editing |Geolocation| Semantic Tags | Video/Audio | Selectors In Progress WebGL | WebSockets | File API | Drag-Drop API | IndexDB | Offline API | Web Workers | HTML5 Forms

  10. IE9 offers support for the most relevant, real-world web patterns that developers are using today as well as the HTML5 patterns we expect to become more mainstream.” -Dean Hachamovitch Corporate VP, IE

  11. html5labs.interoperabilitybridges.com + Platform Previews ie.microsoft.com/testdrive

  12. CSS 2.1 Selectors CSS Color CSS 2 25+ Drafts Transitions Transformations Animations Gradients CSS3 Text Backgrounds & Borders Media Queries Multi-column

  13. -moz-border-radius: 5px 5px5px5px; -webkit-border-radius: 5px; border-radius: 5px; -moz-box-shadow: 2px 2px2px #333; -webkit-box-shadow: 2px 2px2px #333; box-shadow: 2px 2px2px #333; -webkit-background-size: 137px 50px; -o-background-size: 137px 50px; background-size: 137px 50px;

  14. Browser Prefixes • -webkit • -moz • -o • -ms “standard” way browsers implement experimental features

  15. WD • LC • CR • PR • RE

  16. What is usable today?

  17. Adoption Strategies Lowest Common Dominator Only use features natively available in all target browsers

  18. Adoption Strategies PolyfillEnriched Only use features either natively available OR available via JavaScript polyfill X X

  19. polyfill (n) poly • fill: JavaScript that implants HTML5 functionality in a browser that does not offer native support

  20. Adoption Strategies Alternate Experiences Only use features available in target browsers AND design alternate experience for other browsers X X X X X X X

  21. progressiveenhancementgracefuldegradation

  22. [Source: Aaron Olaf, Flickr]

  23. [Source: Mercedes USA, http://mbusa.com/]

  24. Adoption Strategies Vertical Target Create experiences targeted at specific browsers (or classes of browsers) X X X X X X X

  25. HTML5 Techniques You can use today

  26. Enriching VS Experience http://bit.ly/vsHTML5 http://bit.ly/vsSVG Add IntelliSense & Schema Validation to Visual Studio 2008/2010 (pre SP1) editor

  27. Older Browsers

  28. Modernizr • Shiv’r + Inspector • Simple way to check feature support • Conditional JS and CSS if (Modernizr.canvas) { //Canvas supported } if (Modernizer.cssColumns){ //Columns supported } //Etc... .multiplebgs div p { /* properties for browsers that support multiple backgrounds */ } .no-multiplebgs div p { /* optional fallback properties for browsers that don't */ } *Don’t use with IE HTML5shiv. One or the other.

  29. Polyfilling & Older Browsers with Modernizr DEMO

  30. Semantic Tags • Tags with meaning <body> <header> </header> <section> <nav></nav> </section> <footer></footer> </body> VS. <body> <div id=“header”> </div> <div id=“content”> <div id=“nav”></div> </div> <div id=“footer”> </div> </body> *Need polyfill to trigger styling in old IE Safe to use today!

  31. Video & Audio • Semantic rich media • Reach more people on more devices Container MP4 H.264 Codec Safe to use today!

  32. Geolocation • Usable on modern browsers + mobile • Requires plug-in for older browsers navigator.geolocation.getCurrentPosition(callback); function callback(position){ varlat = position.coords.latitude; varlng = position.coords.longitude; varacc = position.coords.accuracy; } Safe to use today!

  33. Local Storage • Usable in modern browsers sessionStorage = per window localStorage = per browser sessionStorage.setItem('value', this.value); localStorage.setItem('value', this.value); sessionStorage.getItem(‘value’); sessionStorage.clear(); localStorage.clear(); 5 MB limit

  34. HTML5 Forms • Improved usability • Uneven support across browsers <form name="f"> <input id="q" autofocus> <!--Technique to support older browsers--> <script> if (!("autofocus" in document.createElement("input"))) { document.getElementById("q").focus(); } </script> <input type="submit" value="Go"> </form> Safe to use today!

  35. SVG & Canvas Safe to use today!

  36. Canvas for IE6/7/8 • Many polyfills for older browsers • JavaScript or Flash based Better Perf

  37. CSS3 Techniques You can use today

  38. CSS3 Selectors • Powerful new selector options //Alternating Items li:nth-child(odd) { color: blue; } li:nth-child(even) { color: green; } li:nth-child(3n) { color: red; } //Every 3rd item //First/Last Items li:first-of-type { color: blue; } li:not(:first-of-type):not(:last-of-type) { color: orange; } //All *but* first/last //Enabled/Disabled input:enabled { border: 2px solid green; } input:disabled { background-color: #BBB; } *Use jQuery to support legacy browsers

  39. CSS3 Color • HSL and RGB • Support for new color models + alpha channels //HSL background:hsl(320,100%,25%); //HSLa background:hsla(165, 100%, 50%, 1.0); //RGB background:rgb(155,100,100); //RGBa background:rgba(153, 134, 117, 0.2);

  40. Custom Fonts • Biggest Problem? • Licensing! @font-face { font-family: Delicious; src: url('Delicious-Roman.otf') format(“opentype”); } //Usage h3 { font-family: Delicious, sans-serif; }

  41. Web Font Providers • Solve the licensing problem • Host the WOFF/TTF/OTF font files • Provide easy-to-use code http://www.fontsquirrel.com/ http://webfonts.fonts.com http://typekit.com/libraries http://code.google.com/webfonts

  42. Borders & Backgrounds • Rounded corners, drop shadows, multi-backgrounds • Expect GD for older browsers //Rounded Corners (Size) border-radius: 5px; //Drop shadow (hShift vShift Size Color) box-shadow: 2px 2px 5px #333; //Background control background: url(top.gif) top left no-repeat,url(bottom.gif) bottom left no-repeat; background-size: 150px 50px; *Use CSS3 PIE to support legacy IE browsers

  43. Gradients • Emerging CSS standard • But useful and desirable • Can be “shived” to support all browsers

  44. Media Queries • Target styles to specific devices… • And features! /*These two rules do the same thing*/ @media all and (min-width:500px) { … } @media (min-width:500px) { … } /*Multiple conditions*/ @media screen and (min-width: 600px) and (max-width: 900px) { .class { background: #333; } }

  45. Tomorrow Land (aka Mobile)

  46. which HTML5/CSS3 technique will you try?

  47. Required Slide Speakers, please list the Breakout Sessions, Interactive Discussions, Labs, Demo Stations and Certification Exam that relate to your session. Also indicate when they can find you staffing in the TLC. Related Content • (DEV348) Debugging Pesky HTML5 Websites with F12 in Windows Internet Explorer 9 • (DEV347) Using JavaScript to Build HTML5 Applications • Web Platforms booth in Microsoft TLC • WebPlaforms TLC • Telerik Booth in Expo Hall

  48. Web Track Resources • http://www.asp.net/ • http://www.silverlight.net/ • http://www.microsoft.com/web/gallery/ • http://www.iis.net/ • http://weblogs.asp.net/Scottgu/ • http://www.hanselman.com/blog/

  49. Resources • Connect. Share. Discuss. http://northamerica.msteched.com Learning • Sessions On-Demand & Community • Microsoft Certification & Training Resources www.microsoft.com/teched www.microsoft.com/learning • Resources for IT Professionals • Resources for Developers http://microsoft.com/technet http://microsoft.com/msdn

More Related