HTML5 - Introduction

6,823 views
6,756 views

Published on

An introduction to some of the new or revised elements and attributes of HTML5.

Published in: Technology, News & Politics
6 Comments
11 Likes
Statistics
Notes
  • Sure, it doesn’t hurt to uppercase DOCTYPE, but there’s no benefit either — unless you’re going all the way and use XHTML5 and not just XHTML-like syntax, which you’re not gonna do because it’s a horrible idea. Why impose all these restrictions upon yourself? Just use whatever feels natural for you and stick with it.
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • @mathias: example on slide 43 was taken from https://developer.mozilla.org/en/Canvas_tutorial/Basic_usage

    You're right, it should be text/javascript or even omitting that (what else would it be). I'll remove it from the slide.

    The DOCTYPE is uppercase was a recommendation given by Molly E. Holzschlag, on one of her workshops. Since I advice to use the XHTML notation, for consistency purposes, it wouldn't hurt to uppercase the DOCTYPE, right?
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Slide 12: “Stick to uppercase `DOCTYPE`” — why? Unless you’re using XHTML5 (and you have to be very sadistic to make that decision) it doesn’t matter.
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Slideshare is messing up my comments.

    I was trying to say, slide 43: script type='application/javascript'?
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Slide 43: <script type='application/javascript'>?? :P
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Views
Total views
6,823
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
198
Comments
6
Likes
11
Embeds 0
No embeds

No notes for slide

HTML5 - Introduction

  1. 1. HTML5 An introductiondonderdag 23 december 2010
  2. 2. ★ WC3 stopped developing HTML in 1999 ★ W3C thought the future would be XML ★ XHTML2 is a beautiful and pure spec, but has no relation to what we actually do, and none to what browsers do. ★ A group of people from Mozilla, Opera and Apple, under the lead of Ian Hickson, started the working group WHATWG and created a spec called Web Applications 1.0donderdag 23 december 2010
  3. 3. The web is moving from a paged document environment to a rich, interactive and forward-thinking webdonderdag 23 december 2010
  4. 4. HTML5 An application centered languagedonderdag 23 december 2010
  5. 5. HTML5 is a spec About 900 pagesdonderdag 23 december 2010
  6. 6. HTML5 spec Don’t try to read or print it, because it is mostly for UA implementorsdonderdag 23 december 2010
  7. 7. ★ Replaces everything that came before (HTML4 and XHTML 1.0) ★ Replacement of DOM2HTML (DOM) ★ No longer looking at a DOM, but at a number of API’sdonderdag 23 december 2010
  8. 8. ★ HTML5 starts where we are today, not where some academics who created XHTML2 want us to be ★ Expanding HTML, to prevent people turning to plugins like Flash and Silverlight, simply because HTML didn’t provide an answer to thatdonderdag 23 december 2010
  9. 9. DOCTYPEdonderdag 23 december 2010
  10. 10. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">donderdag 23 december 2010
  11. 11. DOCTYPE <!DOCTYPE html>donderdag 23 december 2010
  12. 12. ★ Is the shortest notation to put the browser in standards mode ★ No DTD ★ No version number ★ Stick to uppercase ‘DOCTYPE’donderdag 23 december 2010
  13. 13. ★ HTML5 uses syntax compatible with both HTML4 and XHTML 1.0 ★ HTML syntax is served as text/html ★ HTML5 can use XML syntax (like XHTML 1.0)donderdag 23 december 2010
  14. 14. This is valid HTML5: <!DOCTYPE html> <meta charset=UTF-8> <title>Page title</title> <p>Look at my sloppy code!</p>donderdag 23 december 2010
  15. 15. WTF? Where’s the html, head and body tag?donderdag 23 december 2010
  16. 16. ★ If you look under the hood, with Firebug, DragonFly or the Web Inspector, then you’ll see that the browser inserts these tags automatically ★ You are, however, not advised to write HTML like that, but just know you can...donderdag 23 december 2010
  17. 17. ★ The XHTML validator cared about uppercase/lowercase, quotes around attributes and trailing slashes. ★ In reality: the browsers never careddonderdag 23 december 2010
  18. 18. XHTML notation Still, I would personally advise you to use the stricter XHTML notation, because of its consistency and cleaner code.donderdag 23 december 2010
  19. 19. HTML5 elements The new kids in towndonderdag 23 december 2010
  20. 20. HTML5 elements for better structuredonderdag 23 december 2010
  21. 21. <section> ★ The section element represents a generic section of a document or application. ★ A section, in this context, is a thematic grouping of content, typically with a heading.donderdag 23 december 2010
  22. 22. <article> ★ a self-contained composition in a document, page, application, or site and that is intended to be independently distributable or reusable, e.g. in syndication. ★ For example: a forum post, a magazine or newspaper article, a blog entry, a user- submitted comment, ...donderdag 23 december 2010
  23. 23. <nav> ★ The nav element represents a section of a page that links to other pages or to parts within the page: a section with navigation links. ★ Only sections that consist of major navigation blocks are appropriate for the nav element.donderdag 23 december 2010
  24. 24. <aside> ★ Represents a section of a page that consists of content that is tangentially related to the content around the aside element, and which could be considered separate from that content. ★ Can be used for typographical effects like pull quotes or sidebars, for advertising, for groups of nav elements, and for other content that is considered separate from the main content of the page.donderdag 23 december 2010
  25. 25. <hgroup> ★ Represents the heading of a section. The element is used to group a set of h1–h6 elements when the heading has multiple levels, such as subheadings, alternative titles, or taglines.donderdag 23 december 2010
  26. 26. <header> ★ Represents a group of introductory or navigational aids. ★ Is intended to usually contain the sections heading (an h1–h6 element or an hgroup element), but this is not required. ★ Can also be used to wrap a sections table of contents, a search form, or any relevant logos.donderdag 23 december 2010
  27. 27. <footer> ★ Represents a footer for its nearest ancestor sectioning content or sectioning root element. ★ Typically contains information about its section such as who wrote it, links to related documents, copyright data, and the like. ★ Footers don’t necessarily have to appear at the end of a section, though they usually do.donderdag 23 december 2010
  28. 28. <address> ★ Represents the contact information for its nearest article or body element ancestor. ★ Must not be used to represent arbitrary addresses (e.g. postal addresses), unless those are in fact the relevant contact information. ★ Typically, it would be included along with other information in a footer element.donderdag 23 december 2010
  29. 29. <figure> ★ Represents some flow content, optionally with a caption, that is self-contained and is typically referenced as a single unit from the main flow of the document. ★ Can be used to annotate illustrations, diagrams, photos, code listings, etc, that could, without affecting the flow of the document, be moved away from that primary content, e.g. to the side of the page, to dedicated pages, or to an appendix.donderdag 23 december 2010
  30. 30. <figcaption> ★ Represents a caption or legend for the rest of the contents of the figcaption element’s parent figure element, if any.donderdag 23 december 2010
  31. 31. <small> ★ The small element represents side comments such as small print. ★ Small print typically features disclaimers, caveats, legal restrictions, or copyrights. Small print is also sometimes used for attribution, or for satisfying licensing requirements. ★ It is only intended for short runs of text.donderdag 23 december 2010
  32. 32. <cite> ★ The cite element represents the title of a work (e.g. a book, a paper, an essay, a poem, etc). ★ This can be a work that is being quoted or referenced in detail (i.e. a citation), or it can just be a work that is mentioned in passing. ★ A person’s name is not the title of a work and the element must therefore not be used to mark up peoples names.donderdag 23 december 2010
  33. 33. <q cite> ★ The q element represents some phrasing content quoted from another source. ★ Content inside must be quoted from another source, whose address, if it has one, may be cited in the cite attribute. The source may be fictional, as when quoting characters in a novel or screenplay.donderdag 23 december 2010
  34. 34. HTML5 elements for other purposesdonderdag 23 december 2010
  35. 35. <time datetime pubdate> ★ Represents either a time on a 24 hour clock, or a precise date in the proleptic Gregorian calendar, optionally with a time and a time- zone offset. ★ Way to encode modern dates and times in a machine-readable waydonderdag 23 december 2010
  36. 36. <time datetime pubdate> ★ The datetime attribute, if present, gives the date or time being specified. Otherwise, the date or time is given by the elements contents. ★ The pubdate attribute is a boolean attribute. If specified, it indicates that the date and time given by the element is the publication date and time of the nearest ancestor article element, or, if the element has no ancestor article element, of the document as a whole.donderdag 23 december 2010
  37. 37. <time datetime pubdate> <time datetime="2007-10-05">October 5</time> <p>I usually have a snack at <time>16:00</time>.</p> <article> <h1>Small tasks</h1> <footer> Published <time pubdate>2009-08-30</time>. </footer> <p>I put a bike bell on his bike.</p> </article>donderdag 23 december 2010
  38. 38. <mark> ★ Represents a run of text in one document marked or highlighted for reference purposes. ★ Can for example be used to highlight words that match some search string.donderdag 23 december 2010
  39. 39. <ruby> ★ “Ruby” are short runs of text alongside the base text, typically used in East Asian documents to indicate pronunciation or to provide a short annotation. ★ So not for embedding ruby code (the programming language) into your document...donderdag 23 december 2010
  40. 40. <wbr> ★ Represents a line break opportunity. <p>And so they sang: &quot;RubyRubyRuby<wbr>Ruuubbbyyy&quot;</p>donderdag 23 december 2010
  41. 41. <canvas> ★ A resolution-dependent bitmap canvas ★ Basically a rectangle in your page where you can use JavaScript to draw anything you want. ★ Can be used for rendering graphs, game graphics or other visual elements on the fly. ★ Has two attributes: width and heightdonderdag 23 december 2010
  42. 42. <canvas> <canvas width="400" height="150"></canvas> <!-- provide alternative content --> <canvas id="clock" width="150" height="150"> <img src="img/clock.png" width="150" height="150" alt="Clock" /> </canvas> // Reference the canvas object var canvas = document.getElementById(clock); // Check for support if(canvas.getContext) { // Get the context var context = canvas.getContext(2d); }donderdag 23 december 2010
  43. 43. <canvas> <html> <head> <script type="application/javascript"> function draw() { var canvas = document.getElementById("canvas"); if (canvas.getContext) { var ctx = canvas.getContext("2d"); ctx.fillStyle = "rgb(200,0,0)"; ctx.fillRect (10, 10, 55, 50); ctx.fillStyle = "rgba(0, 0, 200, 0.5)"; ctx.fillRect (30, 30, 55, 50); } } </script> </head> <body onload="draw();"> <canvas id="canvas" width="150" height="150"></canvas> </body> </html>donderdag 23 december 2010
  44. 44. Video in HTML5 It’s rather complicateddonderdag 23 december 2010
  45. 45. <video> ★ For embedding video into a webpage ★ One <video> element can link to multiple video files, and the browser will choose the first video it can actually play. ★ It is up to you to know which browsers support which containers and codecs.donderdag 23 december 2010
  46. 46. <video> ★ There is no single combination of containers and codecs that works in all HTML5 browsers. ★ This is not likely to change in the near future. ★ To make your video watchable across all of these devices and platforms, you’re going to need to encode your video more than once.donderdag 23 december 2010
  47. 47. <video> <!-- Basic embedding --> <video src="somefile.ogv"></video> <!-- Specify video dimensions and enable controls --> <video src="somefile.ogv" width="320" height="240" controls></video> <!-- Video will start downloading (but not playing) as soon as page loads --> <video src="somefile.ogv" width="320" height="240" preload></video> <!-- Enable autoplay --> <video src="somefile.ogv" width="320" height="240" autoplay></video>donderdag 23 december 2010
  48. 48. <video> <!-- Realistic example --> <video width="320" height="240" controls> <source src="somefile.mp4" type="video/mp4; codecs=avc1.42E01E, mp4a.40.2" /> <source src="somefile.webm" type="video/webm; codecs=vp8, vorbis" /> <source src="somefile.ogv" type="video/ogg; codes=theora, vorbis" /> <!-- provide Flash player fallback here --> </video> ★ The benefit of specifying the type attribute is that the browser will check it first. ★ If the browser decides it can’t play a particular video, it won’t download the file.donderdag 23 december 2010
  49. 49. HTML5 forms Wassup with that?donderdag 23 december 2010
  50. 50. New input types Backwards compatibledonderdag 23 december 2010
  51. 51. <input type=email> ★ Tells the browser not to submit the form, unless the user has entered a valid email address ★ multiple attribute is allowed, which means the field can be a list of comma-seperated valid email addressesdonderdag 23 december 2010
  52. 52. <input type=url> ★ Causes the browser to ensure that the entered field is a correct URL. ★ Browser may offer the user assistance and show a list of recently visited URLs.donderdag 23 december 2010
  53. 53. <input type=date> ★ Dates were tricky for a user to enter and therefore we relied on JavaScript solutions for displaying a datepicker. ★ Browsers will display a (popup) calendar widget. ★ Browser will now also know what you mean. Previously, datepickers were just a collection of <div>s, <span>s, and links with lots of JavaScript behavior attached.donderdag 23 december 2010
  54. 54. Date / time related input types <!-- for calendar date pickers --> <input type="date" /> <!-- for months --> <input type="month" /> <!-- for weeks --> <input type="week" /> <!-- for timestamps --> <input type="time" /> <!-- for precise, absolute date/timestamps --> <input type="datetime" /> <!-- for local dates and times --> <input type="datetime-local" />donderdag 23 december 2010
  55. 55. <input type=number> ★ Throws an error if the user doesn’t enter a numeric value. ★ Works with min, max and step attributes. ★ Browsers (such as Opera) can render it as a spinner control.donderdag 23 december 2010
  56. 56. <input type=range> ★ Renders as a slider. ★ Used to be JavaScript driven elements, but now the responsability of creating accessibile sliders is moved from the developer to browser vendors.donderdag 23 december 2010
  57. 57. <input type=search> ★ Expects a search term. ★ Attribute placeholder can be provided. This text will only display when the search field has no focus. ★ In Safari on Mac, it takes the default OS search box appearance. This can be overwritten: input[type="search"] { -webkit-appearance: textfield; }donderdag 23 december 2010
  58. 58. <input type=tel> ★ Expects a telephone number. ★ Doesn’t enforce numeric-only input. ★ As mobile phones “know” their own number, most of them might autocomplete this field. ★ The iPhone brings up a telephone input keyboard.donderdag 23 december 2010
  59. 59. <input type=color> ★ Allows the user to input a color value via a picker. ★ Current support is very limited.donderdag 23 december 2010
  60. 60. New attributes To spice your elementsdonderdag 23 december 2010
  61. 61. The list attribute ★ Hooks up with a new element <datalist> ★ Reminiscent of a select box, but user can input own values, if they don’t want to choose one on the predefined options. ★ The id of the <datalist> is referenced in the vaue of the list attribute. ★ It’s possible to dynamically repopulate the options as the user types and thus recreating a Google Suggest functionality.donderdag 23 december 2010
  62. 62. The list attribute <input id="salutation" type="text" list="salutations"> <datalist id="salutations"> <option label="Mr" value="Mr"> <option label="Ms" value="Ms"> <option label="Prof" value="Professor"> </datalist> ★ Example on Google Suggestdonderdag 23 december 2010
  63. 63. Other attributes <!-- placeholder attribute --> <input type="search" placeholder="Zoeken..." /> <!-- required attribute --> <input type="email" required /> <!-- multiple attribute (for multiple uploads or email addresses) --> <input type="file" multiple /> <!-- pattern attribute (match input to custom regular expression) --> <!-- you can include a hint: placeholder="9AAA" --> <input pattern="[0-9][A-Z]{3}" title="A digit follow by three uppercase letters" />donderdag 23 december 2010
  64. 64. So, when can we start using HTML5?donderdag 23 december 2010
  65. 65. So, when can we start using HTML5? Today!donderdag 23 december 2010
  66. 66. Using HTML5 ★ Modernizr Modernizr is a small and simple JavaScript library that helps you take advantage of emerging web technologies (CSS3, HTML5) while still maintaining a fine level of control over older browsers that may not yet support these new technologies. ★ HTML5 Boilerplate A rock-solid default for HTML5 awesome.donderdag 23 december 2010
  67. 67. Interesting booksdonderdag 23 december 2010
  68. 68. Interesting websites ★ http://html5doctor.com ★ http://diveintohtml5.org ★ http://html5demos.com ★ http://www.html5rocks.com ★ http://caniuse.comdonderdag 23 december 2010
  69. 69. The end Questions?donderdag 23 december 2010

×