Skip navigation.

ODIN Blog

Opera Developer Network

Posts tagged with "HTML5"

Canvas and SVG - which should I use when?

, ,

As use of HTML5 is spreading, canvas and SVG (Scalable Vector Graphics) are being more widely used to create images within a web page. They are both supported by all major browsers (except Internet Explorer 8 and below) and are open alternatives to Flash for animation and graphic interaction. Why do we need two image-creation methods, however, and when should either be used?

What is SVG?
  • Has been a W3C standard for several years.
  • XML-based language using tags to create image objects.
  • Resize as much as you want without losing quality.
  • Every element is available within the SVG DOM so you can attach JavaScript events to them.
  • Editing a single object or group of objects is easy.
  • Slows down with a large number of objects.
  • SVG is accessible - text is selectable just like regular text. Accessibility software needs to catch up, however.

What is canvas?
  • At the time of writing, part of the HTML5 specification.
  • Pixel-based images using JavaScript to edit pixels.
  • Images become pixellated when enlarged.
  • Everything is drawn with pixels. To change anything in the image you have to edit the pixels.
  • Redrawing the pixels in the canvas area is fast.
  • Slows down with a large drawing area.
  • Canvas is not accessible (as of late 2009) - text is unreadable by e.g. screen readers and search engines.

So what are canvas and SVG best suited for?
Because of its speed of manipulation, canvas is best when fast rendering and redrawing is needed, e.g. animations and games, such as in this example: http://www.benjoffe.com/code/demos/canvascape/

SVG is better suited for large-scale rendering and interactivity, e.g. maps and user interfaces, such as in this slideshow demo: http://people.mozilla.com/~vladimir/demos/photos.svg

It should also be noted that it's not necessarily a choice of using one or the other. If required, there's a happy middle ground where SVG and canvas can be layered together to make the most of their respective strengths.

N.B. To work around Internet Explorer's lack of support, please look at explorercanvas for canvas capability and Raphael for cross-browser vector graphics.

Further reading: SVG vs. Canvas on Trivial Drawing Application

Standards.Next CSS3 event coming soon to the big apple

, , , ...

With two successful Standards.Next events behind us, we are taking the show on the road to the Big Apple for an event focusing on CSS3. As always, the event is free and anyone can attend. Standards.Next CSS3 will take place on the 20th November at the Time-Life building in New York City. Time & Life Inc. have generously let us use one of there rooms for the day. Space will be limited so please register your interest on the events Upcoming page. If we reach capacity people will be admitted on a first come, first served basis, so please turn up early if you want to absolutely guarantee a spot. We hope to have space for everyone though.

For a free event we have a stellar line up of speakers, and you could be amongst them. At the present moment we have confirmed that Molly E. Holzschlag and Håkon Wium Lie of Opera will be presenting, along with top selling CSS author Andy Budd and Internet Explorer Product Manager Pete Le Page. We will also have lighting talks from interested participants.

The Web design world has been abuzz about CSS3 for along time now, with border-radius being the poster child, along with Web Fonts. We will show these and the many more features of CSS3 that are available now and the near future. With at least two members of the CSS Working Group in attendance, the event will be a perfect way to give feedback on the current and future direction of CSS. We are looking forward to meeting some of your there.

HTML5 at London Web Standards

I was privileged to be invited to come and present at London Web Standards, and honoured that the tickets sold out within 45 minutes of being available. So, no pressure then ...

Assisted by the lovely Henny who advanced my slides and alt-tabbed from slideshow to demo, I sneezed and snuffled my way through a presentation called HTML5 and Friends (PDF, 723K).

The resources that I demoed were

You can also download Opera 10 which I was using to demo.

Opera Developer Network has some beginner's canvas tutorials available:

  1. HTML 5 canvas - the basics
  2. Creating an HTML 5 canvas painting application
  3. Creating pseudo 3D games with HTML 5 canvas and raycasting
  4. Creating pseudo 3D games with HTML 5 canvas and raycasting: Part 2

For the second half of the talk, I built an HTML5 page through the magic of live coding (with lavish prizes!).

Consequently there are no slides to publish, but I have an article called Designing a blog with HTML that covers the same ground. (Two articles on my personal blog cover it in much more detail: Redesigning with HTML 5 and WAI-ARIA and Marking up a blog with HTML 5 (part 2).)

The shocking looseness of HTML5's validation rules is discussed in an article I wrote called HTML 5 + XML = XHTML 5. The main take-home should be that, although you can mix quoted or unquoted attributes, upper and lower case freely (even in the same page), you shouldn't: if you do, you'll make your code an unreadable and therefore unmaintainable mess. Choose one coding convention that works for you and stick to it.

Some other useful resources:

Thanks to all who attended and asked great questions. I'm sorry that I had to charge off before the bar shut (not like me at all!) but my son was sick so I needed to get the last train home.

Tomorrow's web standards today - British Computer Society presentation, Surrey University

, , , ...

I had the pleasure of speaking to a really savvy crowd at Surrey University last night on "Tomorrow's web standards today".  It was a fun session with lots of really good questions at the end - just the way I like it.

Below are my slides written in HTML. They're best viewed in Opera on full screen (View > Full screen) but of course work in any browser.Demos for <video>, <canvas>, SVG, web forms, widgets and media queries are all either linked from the presentation or bundled together in the download.

Tomorrow's web standards today, 6.8MB

Future of Web Apps London: HTML5

, , , ...

I was privileged to be invited to speak on HTML5 at Future of Web Apps London last week. My talk was called HTML5: The Future of Web Applications (PDF 636K). It's a newly written talk that concentrates on the apps side of the language, rather than the markup side that I usually show. That seemed appropriate given the apps-focus of the show, and the HTML5 editor's assertion that HTML5 is

extending the language to better support Web applications, since that is one of the directions the Web is going in and is one of the areas least well served by HTML so far. This puts HTML in direct competition with other technologies intended for applications deployed over the Web, in particular Flash and Silverlight.

The video is now available, as is a transcript.

The resources that I demoed were

You might also want to check out

Opera Developer Network has some beginner's canvas tutorials available:

  1. HTML 5 canvas - the basics
  2. Creating an HTML 5 canvas painting application
  3. Creating pseudo 3D games with HTML 5 canvas and raycasting
  4. Creating pseudo 3D games with HTML 5 canvas and raycasting: Part 2

Early the next morning, I was woken by the organisers asking me to do a second talk. As I had no time to prepare, I coded an HTML5 page live. Five minutes before going on stage, my laptop died; thanks so much to the guys on the Microsoft stand who lent me a replacement Windows machine, installed the necessary software and got my lappie running again!

Consequently there are no slides to publish, but I have an article called Designing a blog with HTML that covers the same ground. (Two articles on this blog cover it in much more detail: Redesigning with HTML 5 and WAI-ARIA and Marking up a blog with HTML 5 (part 2).)

Some other useful resources:

You can also download Opera 10 which I was using to demo.

There is a snippet of an interview with me about HTML5 and mobile by Natali del Conte.

Finally, thanks to all those who came along and gave me great feedback. I was literally hoarse from chatting in the breaks, in the pub and everywhere else about HTML5. The biggest gripe (apart from those appalled by the fact that you can use XML syntax or not, as you wish) was the stylability of the new form elements and their error messages. I'd love to hear your feedback on this.