Вы находитесь на странице: 1из 10

HTML 5

Introduction HTML 5 :

What is HTML 5?

HTML5 is the next generation of HTML, superseding HTML 4.01,


XHTML 1.0, and XHTML 1.1. HTML5 provides new features that are necessary for
modern web applications. It also standardizes many features of the web platform that
web developers have been using for years, but that have never been vetted or
documented
by a standards committee. (Would it surprise you to learn that the Window object
has never been formally documented? In addition to the new features, HTML5 is the
first attempt to formally document many of the “de facto” standards that web browsers
have supported for years.)
Like its predecessors, HTML5 is designed to be cross-platform. You don’t need to be
running Windows or Mac OS X or Linux or Multics or any particular operating system
in order to take advantage of HTML5. The only thing you do need is a modern web
browser. There are modern web browsers available for free for all major operating
systems. You may already have a web browser that supports certain HTML5 features.
The latest versions of Apple Safari, Google Chrome, Mozilla Firefox, and Opera all
support many HTML5 features. (You’ll find more detailed browser compatibility tables
throughout this book.) The mobile web browsers that come preinstalled on iPhones,
iPads, and Android phones all have excellent support for HTML5. Even Microsoft has
announced that the upcoming Version 9 of Internet Explorer will support some
HTML5 functionality.

HTML5 will be the new standard for HTML, XHTML, and the HTML DOM.
The previous version of HTML came in 1999. The web has changed a lot since then.
HTML5 is still a work in progress. However, most modern browsers have some HTML5
support.
How Did HTML5 Get Started?
HTML5 is a cooperation between the World Wide Web Consortium (W3C) and the Web
Hypertext Application Technology Working Group (WHATWG).
WHATWG was working with web forms and applications, and W3C was working with
XHTML 2.0. In 2006, they decided to cooperate and create a new version of HTML.
Some rules for HTML5 were established:
• New features should be based on HTML, CSS, DOM, and JavaScript
• Reduce the need for external plugins (like Flash)
• Better error handling
• More markup to replace scripting
• HTML5 should be device independent
• The development process should be visible to the public
New Features
Some of the most interesting new features in HTML5:
• The canvas element for drawing
• The video and audio elements for media playback
• Better support for local offline storage
• New content specific elements, like article, footer, header, nav, section
• New form controls, like calendar, date, time, email, url, search
Browser Support
The latest versions of Safari, Chrome, Firefox, and Opera support some HTML5 features.
Internet Explorer 9 will support some HTML5 features.
ELEMEN BARU :

The Canvas Element

New Media Elements


Global Structure :

1. Video

Video on the Web


Until now, there has never been a standard for showing video on a web page.
Today, most videos are shown through a plugin (like flash). However, not all browsers have
the same plugins.
HTML5 specifies a standard way to include video, with the video element.
Video Format :
Sintax :

<!DOCTYPE HTML>
<html>
<body>

<video width="320" height="240" controls="controls">


<source src="movie.ogg" type="video/ogg" />
<source src="movie.mp4" type="video/mp4" />
Your browser does not support the video tag.
</video>

</body>
</html>

All <video> Attributes

2. Audio

Until now, there has never been a standard for playing audio on a web page.
Today, most audio are played through a plugin (like flash). However, not all browsers
have the same plugins.
HTML5 specifies a standard way to include audio, with the audio element.
The audio element can play sound files, or an audio stream.

<audio id="audio" src="sound.mp3" controls></audio>


document.getElementById("audio").muted = false;

Audio Formats
<!DOCTYPE HTML>
<html>
<body>

<audio src="westlife.ogg" controls="controls">


<audio src="westlife.mp3" controls="controls">
Your browser does not support the audio element.
</audio>

</body>
</html>

All <audio> Attributes

3. Canvas

What is Canvas?
The HTML5 canvas element uses JavaScript to draw graphics on a web page.
A canvas is a rectangular area, and you control every pixel of it.
The canvas element has several methods for drawing paths, boxes, circles, characters, and
adding images.

<canvas> is a new HTML element which can be used to draw graphics using scripting
(usually JavaScript). It can for instance be used to draw graphs, make photo compositions or
do simple (and not so simple) animations. The image on the right shows some examples of
<canvas> implementations which we will see later in this tutorial.
<canvas> was first introduced by Apple for the Mac OS X Dashboard and later implemented
in Safari. Gecko 1.8-based browsers, such as Firefox 1.5, also support this new element. The
<canvas> element is part of the WhatWG Web applications 1.0 specification also known as
HTML 5.
In this tutorial I will try to describe how to implement the <canvas> element in your own
HTML pages. The examples provided should give you some clear ideas what you can do with
<canvas> and can be used to start building your own implementations.

<!DOCTYPE HTML>
<html>
<body>

<canvas id="myCanvas" width="200" height="100" style="border:1px


solid #c3c3c3;">
Your browser does not support the canvas element.
</canvas>

<script type="text/javascript">

var c=document.getElementById("myCanvas");
var cxt=c.getContext("2d");
cxt.fillStyle="pink";
cxt.fillRect(0,0,150,75);

</script>

</body>
</html>

Draw With JavaScript


The canvas element has no drawing abilities of its own. All drawing must be done inside a
JavaScript:
<script type="text/javascript">
var c=document.getElementById("myCanvas");
var cxt=c.getContext("2d");
cxt.fillStyle="#FF0000";
cxt.fillRect(0,0,150,75);
</script>

avaScript uses the id to find the canvas element:


var c=document.getElementById("myCanvas");
Then, create a context object:
var cxt=c.getContext("2d");
The getContext("2d") object is a built-in HTML5 object, with many methods to draw paths,
boxes, circles, characters, images and more.
The next two lines draws a red rectangle:
cxt.fillStyle="#FF0000";
cxt.fillRect(0,0,150,75);

<canvas id="canvas" width="838" height="220"></canvas>

<script>
var canvasContext = document.getElementById("canvas").getContext("2d");
canvasContext.fillRect(250, 25, 150, 100);

canvasContext.beginPath();
canvasContext.arc(450, 110, 100, Math.PI * 1/2, Math.PI * 3/2);
canvasContext.lineWidth = 15;
canvasContext.lineCap = 'round';
canvasContext.strokeStyle = 'rgba(255, 127, 0, 0.5)';
canvasContext.stroke();
</script>

Contoh Canvas :
Canvas 3D (WebGL) :

<canvas id="canvas" width="838" height="220"></canvas>

<script>
var gl = document.getElementById("canvas").getContext("experimental-
webgl");
gl.viewport(0, 0, canvas.width, canvas.height);
...
</script>

4. Embed

Definition and Usage


The <embed> tag defines embedded content, such as a plug-in.
Atribut :

5. Source
Definition and Usage
The <source> tag defines media resources for media elements, such as <video> and
<audio>.

Perkembangan Aplikasi web :


Kelebihan dan kekurangan HTML 5

Beberapa kelebihan yang dijanjikan pada HTML 5:

* Dapat ditulis dalam sintaks HTML (dengan tipe media text/html) dan XML.

* Integrasi yang lebih baik dengan aplikasi web dan pemrosesannya.

* Integrasi ('inline') MathML dan SVG dengan doctype yang lebih sederhana.

* Penulisan kode yang lebih efisien.

* Dapat dimengerti oleh peramban lawas (backwards compatible). Sehingga


istilah 'deprecated' tidak akan diperlukan lagi.

Yang masih diperdebatkan dalam pengembangan HTML 5:

* Makna semantik beberapa elemen presentasioal.

* Fitur aksesibilitasnya. Seperti atribut alt dan summary.

Вам также может понравиться