HTML Interview Questions and Answers

HTML stands for Hypertext Markup Language. It is the standard markup language for creating Web pages. Hypertext refers to the hyperlinks that an HTML page may contain. Markup refers to the way tags are used to define the page layout and elements within the page.


1) What is HTML5?

HTML5 introduces the localStorage attribute which would be used to access a page's local storage area without no time limit and this local storage will be available whenever you would use that page.


2) What is the use of Canvas element?

The canvas element helps to build charts, graphs, bypass Photoshop to create 2D images and place them directly into HTML5 code.


3) Tell me two benefits of HTML5 Web Storage?

Two main benefits of HTML5 Web Storage: It can store up to 10 MB data which is certainly more than what cookies have. Web storage data cannot be transferred with the HTTP request. It helps to increase the performance of the application.


4) What is Web Forms 2.0?

Web Forms 2.0 is an extension to the forms features found in HTML4. Form elements and attributes in HTML5 provide a greater degree of semantic mark-up than HTML4 and remove a great deal of the need for tedious scripting and styling that was required in HTML4.


5) What is the purpose of 'output' tag in HTML5?

HTML5 introduced a new element which is used to represent the result of different types of output, such as output written by a script.


6) What is the purpose of 'required' attribute in HTML5?

HTML5 introduced a new attribute called required which would insist to have a value in an input control.


7) What is Server Side Events in HTML5?

Along with HTML5, WHATWG Web Applications 1.0 introduces events which flow from web server to the web browsers and they are called Server-Sent Events (SSE). Using SSE you can push DOM events continously from your web server to the visitor's browser. The event streaming approach opens a persistent connection to the server, sending data to the client when new information is available, eliminating the need for continuous polling. Server-sent events standardizes how we stream data from the server to the client.


8) What is Geolocation API in HTML?

HTML5 Geolocation API lets you share your location with your favorite web sites. A Javascript can capture your latitude and longitude and can be sent to backend web server and do fancy location-aware things like finding local businesses or showing your location on a map. Today most of the browsers and mobile devices support Geolocation API. The geolocation APIs work with a new property of the global navigator object ie. Geolocation object which can be created as follows: var geolocation = navigator.geolocation; The geolocation object is a service object that allows widgets to retrieve information about the geographic location of the device.


9) What is purpose of getCurrentPosition() method of geolocation object of HTML5?

This method retrieves the current geographic location of the user.


10) What is purpose of watchPosition() method of geolocation object of HTML5?

This method retrieves periodic updates about the current geographic location of the device.