HTML5 examples
Here's a collection of HTML5 examples and demonstrations. It's constantly being added to and if you have one that you'd like to see here, email it to me.
- HTML5 canvas examples
- HTML5 video
- HTML5 audio
- HTML5 GeoLocation
- HTML5 DOM storage
- HTML5 Form elements
- WebKit Desktop notifications
- CSS Box shadow
- CSS Border radius
- CSS opacity
- CSS gradients
- CSS reflections
- CSS @font-face
- Tutorials and resources
HTML5 canvas examples
The canvas tag is a Javacript controlled 2D drawing area. There's more information on it here.
Graphs and data visualisation
Applications
- Create a Drawing App with HTML5 Canvas and JavaScript
- A sketch program
- Cartoon Builder
- Harmony - a drawing tool
- Bespin
- Sketchpad
- CanvasPaint
Games
- Sinuous
- Pacman
- Galatic Plunder
- A block game (use your cursor keys)
- 3D tetris - CubeOut
- UFO
- Defender
- Tetris
- Thrust
- Etchaphysics
- A shapes game (can you guess I didn't read the instructions...?)
- An (addictive) canvas game with balls
- Coverfire
- Chain Reaction (addictive)
- Spectrum Emulator
- JS Wars
- Berts Breakdown
- Asteroids
- Jetris
- RayCaster
- Slide puzzle
- A first person shooter
- A torus style game
- Super Mario Kart
- Breakout
- Breakout
- Twitch
- 3Bored
Clocks
Other
- jTenorion
- Lightening example
- Canvas Cycle (color cycling, not a bicyle)
- Tiler 3D
- Magnetic
- Geography test (hone your skills)
- Identicons
- Kaleidoscope
- Bomomo
- Remaking an image
- Ultralight K3D demo
- Moving particles
- Googlebox
- Flickr in 3D
- Parallax demos
- Liquid particles
- Kaleidoscope
- Mathnimatics
- CanvasMol
- A few high quality examples
- Nebula cloud
- Video destruction
- 3D examples (very impressive)
- Animated examples
- Space image effects
- Particle animation demo
- Space debris
- Trippy patterns
- Trippy Chillis
- "Many Lines"
- Wave form doobry
- Rising bubbles
- Audio/Canvas experiment
- An animation of a dragon
- An image evolution algorithm
- Gartic Canvas Sketch
- Jigsaw puzzle
- Physics example (very good, takes a little while to load)
- A big green worm...?
- Pretty patterns
- Chrome Experiments
- PhysicSketch
- Canvas Shell
- Canvas and native text functions
- CanvasBalls
- Handwriting recognition
- Pie Menu
- Blob
- Starfield
- Image reflection
- Movement tracker
- Yahoo! Pipes
- A basic shapes example
- Drawing example
HTML5 Video
This will be rather useful. A simple way to embed video in your pages. An example of the code is:
<video controls width="300" height="300" loop>
<source src="/html5/video.webm">
<source src="/html5/video.ogg">
</video>
Possible attributes include:
- src - The source URL of the video
- poster - This is the URL of a placeholder image
- preload - A boolean type attribute controlling whether the resource is automatically fetched - can be none, metadata or auto.
- autoplay - A boolean attribute that determines whether the video starts playing automatically or not
- loop - A boolean attribute that determines whether the video loops or not
- controls - A boolean attribute that determines whether the video controls are shown or not
- width - The width in pixels of the element
- height - The height in pixels of the element
Note about codecs
A group of "biggies" recently announced WebM - a free video codec for web video. Some browsers already have support for it - I've tried Chrome 6 and Opera 10.5. Firefox 3.6 and Chrome 5 (to name two) don't appear to support WebM (so you'll see the Ogg squid video).HTML5 Audio
Also potentially very useful is the new <audio> tag. It makes embedding audio in your pages a very simple affair. It shares a lot of the <video> tag attributes:
- src - The source of the audio file
- autoplay - Whether to start playing the file automatically
- controls - Whether to show the controls or not
- preload - Whether to start loading the resource along with the page
- loop - Whether to keep playing the audio file
<audio src="/html5/audio.mp3" controls ></audio>
HTML5 GeoLocation
One of the features of HTML5 is location tracking called GeoLocation. It works by using geographical data which is associated with internet hardware (routers/switches/repeaters etc). There's a more detailed example of this here. This example also demonstrates how you can use the geographical data and plug it into a mapping service to get something usable.
HTML5 DOM storage
As used by the RGraph annotations feature to facilitate persistence, HTML5 DOM storage is an alternative to cookies for local storage. It has key advantages, like more storage space and the fact that it's not transmitted over the wire. There's more on HTML5 DOM storage here.
HTML5 Form elements
range input
Currently a mixed bag regarding support, however Chrome support is good. This input type is rendered as a slider bar:
Possible attributes include min and max, which don't really need explaining, do they?Placeholder text
Commonly done with Javascript, this new attribute for text inputs puts text in the input until you focus on the element.
The autofocus attribute
Also commonly done with Javascript, this attribute can bring focus to the element automatically. Care should be taken though when using this attribute as if it is on an element that is not in view by default, it can cause the page to "jump".
<input type="text" autofocus >
WebKit Desktop notifications
Not strictly speaking an HTML5 thing (rather, it's a WebKit thing), but it's been present in Google Chrome since version 4. There's a more detailed article about this here: http://www.phpguru.org/article/html5-webkit-desktop-notifications-example
CSS Box shadow
CSS3 now sports the box-shadow: property which makes adding drop shadows to your elements very easy. There are currently a few proprietary properties that you might want to use alongside this to try and get maximum coverage. Even Internet Explorer 9 supports this property, and previous versions have a drop shadow effect available using DirectX and the filter: property. The values of the ox-shadow property are the X and Y offsets (which can be negative too) and the severity of the blurring.
box-shadow: black 3 3 3; -moz-box-shadow: black 3 3 3; -webkit-box-shadow: black 3 3 3; filter: progid:DXImageTransform.Microsoft.Shadow(color=#666666,direction=135);
CSS Border radius
The CSS border radius allows you to very easily achieve curvy corners without using images. Instead of the drudgery of producing curvy corners with images, it's now simply a case of specifying a few CSS properties.
border-radius: 5px; -moz-border-radius: 5px; border: 2px solid black;
CSS opacity
CSS3 opacity allows you to specify the opacity (transparency) of an element. You can read more about it here: http://www.phpguru.org/static/css3
CSS Gradients
WebKit and Firefox support creating and using gradients in CSS. Even MSIE has had this facility for a while, albeit in a non-standard limited fashion: http://www.phpguru.org/article/css3-gradients
CSS Reflections
WebKit based browsers (currently Chrome and Safari) support something called CSS reflections. This means you can produce a mirror image of an element (supposedly any). There's an article on reflections here: http://www.phpguru.org/webkit-css-reflections
CSS @font-face
@font-face was first prposed for CSS2 and has been implemented by Internet Explorer since version 5. It used the .eot format though. Now you can use .ttf and .otf. It simply allows you to specify fonts that the user doesn't have on their computer. These fonts are then downloaded by the users browser and used.
@font-face {
font-family: Delicious;
src: url('Delicious-Roman.otf');
}
@font-face {
font-family: Delicious;
font-weight: bold;
src: url('Delicious-Bold.otf');
}
Some text in Delicious Roman
Tutorials and resources
Here's a collection of tutorials and resources for HTML5 in general.
- HTML5 Demos at seogadget.co.uk
- 30 very useful HTML5 tutorials techniques and examples
- 10 HTML5 Demos at webdesignledger.com
- HTML5 resources at sixrevisions.com