HTML5 is the fifth and current version of HTML, a markup language used to structure and present content on the World Wide Web. This article will help readers understand it. HTML5 was developed through a collaboration between W3C and the Web Hypertext Application Technology Working Group. It is a higher version of HTML with many new elements that can make your pages more semantic and dynamic. It was developed to provide a better Web experience for everyone. HTML5 provides many features to make the Web more dynamic and interactive. The new features of HTML5 are:
HTML5 is not an official standard yet, so not all browsers support it or some of its features. One of the most important reasons behind the development of HTML5 is to prevent users from downloading and installing multiple plugins like Silverlight and Flash. New Tags and Elements
Figure 1: Semantic elements Figure 2: Form elements Figure 3: Graphical elements Figure 4: Media elements Advanced Features of HTML5 Location This is an HTML5 API that is used to obtain the geographic location of a website user, who must first allow the website to obtain his or her location. This is usually done via a button and/or browser pop-up. All latest versions of Chrome, Firefox, IE, Safari, and Opera can use HTML5 geolocation capabilities. Some uses of geolocation are:
How it works: Geolocation works by scanning common sources of location information, including the following:
The API provides very convenient functions to detect geolocation support in the browser:
The getCurrentPosition API is the primary method for working with geolocation. It retrieves the current geolocation of the user's device. The location is described as a set of geographic coordinates along with a heading and speed. The location information is returned as a Location object. The syntax is:
There are two ways we can provide location information to users: geodetic and civil.
As shown in Table 1 below, each attribute/parameter has both geodetic and civil representations. Figure 5 contains the set of properties returned by a location object. Figure 5: Location object properties Network storage In HTML, in order to store user data locally, we need to use JavaScript cookies. To avoid this, HTML5 has introduced Web Storage, which is used by websites to store user data locally. Compared with cookies, the advantages of Web Storage are:
There are two types of Web Storage objects:
How it works: The localStorage and sessionStorage objects create a key=value pair. For example: key="Name", value="Palak". These are stored as strings, but can be converted if necessary using JavaScript functions such as parseInt() and parseFloat(). Given below is the syntax for using Web Storage object:
Application Cache (AppCache) Using HTML5 AppCache, we can make our web applications work offline without an Internet connection. All browsers except IE can use AppCache (as of this time). The advantages of application caching are:
A cache manifest is a simple text file that lists the resources that the browser should cache for offline access. The manifest attribute can be included in the HTML <head> tag of a document, like this:
It should be on all pages you want to cache. Cached application pages remain in place unless:
video Before HTML5 was released, there was no unified standard to display videos on web pages. Most videos were displayed through different plug-ins such as Flash. But HTML5 specifies a standard way to display videos on web pages using the video element. Currently, the video element supports three video formats, as shown in Table 2. The following example shows the use of the video element:
The examples use an Ogg file and should work in Firefox, Opera, and Chrome. To make the video work in Safari and future versions of Chrome, we have to add an MPEG4 and WebM file. The video element allows multiple source elements. The source elements can link to different video files. The browser will use the first recognized format, as shown below:
Figure 6: Canvas output Audio For audio, the situation is similar to video. Before the release of HTML5, there was no unified standard for playing audio on a web page. Most audio was also played through different plug-ins such as Flash. But HTML5 specifies a standard way to play audio on a web page by using the audio element. The audio element is used to play sound files and audio streams. Currently, the HTML5 audio element supports three audio formats, as shown in Table 3. The audio element is used as follows:
This example uses an Ogg file and should work in Firefox, Opera, and Chrome. To make the audio work in future versions of Safari and Chrome, we must add an MP3 and Wav file. The audio element allows multiple source elements, which can link to different audio files. The browser will use the first recognized format, as shown below:
Canvas To create graphics on a web page, HTML5 uses the canvas API. We can draw anything with it, and it uses JavaScript. It improves website performance by avoiding downloading images from the network. Using canvas, we can draw shapes and lines, arcs and text, gradients and patterns. Moreover, canvas allows us to manipulate pixels in images and even in videos. You can add the canvas element to an HTML page as follows:
The canvas element does not have the functionality to draw elements. We can achieve drawing by using JavaScript. All drawing should be done in JavaScript.
The output of the above script is shown in Figure 6. You can draw many objects like arcs, circles, lines/vertical gradients etc. HTML5 Tools To operate effectively, all skilled or amateur web developers/designers should use HTML5 tools, which are very helpful when it comes to setting up workflows/websites or performing repetitive tasks. They improve the usability of web design. Here are some essential tools to help create an awesome website.
|
<<: Tech Neo Technology Salon 15th Special Report - How CDN Makes the Network Smarter
>>: How to solve some problems encountered in Xcode9 and iOS 11
Social data, search data, and multi-line product ...
Author: Scientific scraps Reviewer: Zhang Wei, As...
Yu Feng Recently, the State Council issued the &q...
Douyin’s traffic comes from two aspects. On the o...
In recent years, lipid-lowering injections have a...
In daily life, we often put the fruits we buy hom...
In August this year, the media widely circulated ...
The new Skylake platform was officially launched ...
The 400 telephone number is a 10-digit number. It...
On June 7, the 2017 Asia Consumer Electronics Sho...
Course Catalog ├──Courseware+color card+brush | ├...
54 years ago today, Armstrong left clear footprin...
The gradual collapse of the Samsung empire has fin...
In the past few days, a lot of sharing and suppor...