Top 7 Features
Multimedia Support
First and foremost feature is the support of multimedia in HTML5. Yes HTML5 supports both audio and video files to be played in a browser. Below is the sample syntax to play audio and video files respectively.
Video & Audio
New Input Element Types
Input elements play an important role in data driven web applications. The input types help in receiving the input in a required format. In HTML5 some new input types have been added. A few of the existing input types are password, file, etc. Below are a few of the important and useful new types introduced in HTML5 for an input HTML control.
- Tel
- url
- color
- datetime
Canvas in HTML5
Canvas is a rectangular area, which allows pixel level operations like drawing a line, box, circle, performing graphics, etc. Now HTML5 offers support for canvas areas. Shown below is a sample code.
<canvas id="myCanvas" width="200" height="100"> Fallback content, when canvas is not supported by the browser. </canvas>
Custom Data Attributes
HTML5 now allows you to add valid data attributes, which helps in storing the data without affecting the web page UI. These data attributes can be added in a hidden manner from the user and can be later used by JQuery or your JavaScript functions. In order to make your custom data attribute valid, the attribute should be prefixed with the word “data”.
<span data-domain="Technology" data-language="C#"> </span>
Editable Contents
This is a nice feature, which allows the end users to edit the HTML control’s content. This kind of feature allows the developers to build web pages that include sections like notes, HTML editor etc. All you need to do is add an attribute named contentEditable=”true” to the HTML control.
<p contenteditable="true">Click here to edit this content!</p>
This feature comes in really handy when it is combined with another feature called offline storage. The topic about the offline storage will be covered in a future article.
Autofocus and Placeholder Attributes
The autofocus feature is achieved by adding the autofocus attribute. This allows the control to have the focus automatically on page load.
<button id="SubmitButton" autofocus></button>
Placeholder is a feature supported for input fields by adding the attribute placeholder. This feature displays the value provided for the placeholder attribute, like a water mark, until the focus is moved to the input control.
<input type="email" name="EmailTextBox" placeholder="Please enter email here..."/>
Required Field and Range Validators
Required field functionality is achieved using the attribute named “required” on the input controls. This makes sure that the form will not be posted until the value is entered for the input control.
<input type="email" name="EmailTextBox" required/>
Range validation is achieved through specifying the min and max values for the input control along with a valid type. This makes sure that the form will not be posted until the value entered for the input control is within the range.
<input type="number" name="NumberOfItems" min="10" max="50" required/>
html5 七大特性:下面是一些HTML5的特性,你会发现它比Flash要强大。
1.支持视频播放功能。
Flash之所以流行的原因之一在于它能够播放视频。而HTML5具备更强大的视频功能,随时可以控制暂停、播放、开始。它强大的功能体系完全可以与YouTube以及其它的Flash网站相媲美。
2.支持视频录制功能
时至今日,这个特性并不流行。据Beccue介绍,这个功能将会变得日趋重要。因为目前所有提供Web访问接口的移动虚拟设备都具备摄像功能。
3.支持音频的播放/录音功能
目前您们在播放/录制音频的时候可能需要用到Flash、Quicktime或者Java,而这也是HTML5的功能之一。
4.应用程序
HTML5允许Web页面运行应用,就像一般的应用那样独立运行。
5.支持丰富的2D图片
HTML5内嵌了所有复杂的二维图片类型。同目前网站加载图片的方式相比,它的运行速度要快得多。
6.支持即时通讯功能
在HTML5中内置了基于Web sockets的即时通讯功能,一旦两个用户之间启动了这个功能,就可以保持顺畅的交流。
7. 实时流
WebSockets将允许任何Web页面设计人员轻松地添加实时数据流(从股票市场价格到上网报告),实时数据流除了要求HTML程序员的能力外,还需要更复杂的编程技能。