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.


11) What is purpose of clearPosition() method of geolocation object of HTML5?

This method cancels an ongoing watchPosition call.


12) What are web sockets?

Web Sockets is a next-generation bidirectional communication technology for web applications which operates over a single socket and is exposed via a JavaScript interface in HTML 5 compliant browsers. Once you get a Web Socket connection with the web server, you can send data from browser to server by calling a send() method, and receive data from server to browser by an onmessage event handler. Following is the API which creates a new WebSocket object. var Socket = new WebSocket(url, [protocal] ); Here first argument, url, specifies the URL to which to connect. The second attribute, protocol is optional, and if present, specifies a sub-protocol that the server must support for the connection to be successful.


13) When a local storage data gets deleted?

local storage data has no time limit. To clear a local storage setting you would need to call localStorage.remove('key'); where 'key' is the key of the value you want to remove. If you want to clear all settings, you need to call localStorage.clear() method.


14) When a session storage data gets deleted?

The Session Storage Data would be deleted by the browsers immediately after the session gets terminated.


15) Name some of the new features of HTML5.

HTML5 introduces a number of new elements and attributes that helps in building a modern websites. Following are great features introduced in HTML5 :

  • New Semantic Elements − These are like <header>, <footer>, and <section>.

  • Forms 2.0 − Improvements to HTML web forms where new attributes have been introduced for <input> tag.

  • Persistent Local Storage − To achieve without resorting to third-party plugins.

  • WebSocket − A a next-generation bidirectional communication technology for web applications.

  • Server-Sent Events − HTML5 introduces events which flow from web server to the web browsers and they are called Server-Sent Events (SSE).

  • Canvas − This supports a two-dimensional drawing surface that you can program with JavaScript.

  • Audio & Video − You can embed audio or video on your web pages without resorting to third-party plugins.

  • Geolocation − Now visitors can choose to share their physical location with your web application.

  • Microdata − This lets you create your own vocabularies beyond HTML5 and extend your web pages with custom semantics.

  • Drag and drop − Drag and drop the items from one location to another location on a the same webpage.


16) Name two new tags included in the HTML 5.

<Video> and <Audio> are new tags which are included in HTML5 version. They are mainly used as a replacement for Flash, Silverlight, and similar technologies to play multimedia items.


17) Do you know which are two semantic tags are included in HTML5 version?

The <article> and <section> tags are two new tags that are included in HTML5. Articles can be composed of multiple sections that can have multiple articles. An article tag represents a full block of content which is a section of a bigger whole.


18) What is <figure> in HTML5?

This tag represents a piece of self-contained flow content. It is mostly used as a single unit as a reference the main flow of the document.


19) What are the new FORM elements which are available in HTML5?

The new Form elements in HTML5 offers much better functionality than the earlier versions.

The tags given provided to carry out these functions are:

1) <datalist> – This tag is use to specify a list of options for input controls.

2) <keygen> – This tag represents a key-pair generator field.

3) <output> – It represents the result of any scripting calculation.


20) Explain five new input types provided by HTML5 for forms?

Following are the important, new data types offered by HTML5:

  1. Date: It allows the user to select a date.
  2. datetime-local: This input type allows the user to select a date and time without time zone.
  3. datetime: This input type allows the user to select a date and time with time zone.
  4. month: It enables the user to select a month and year
  5. email: These input fields used to contain an e-mail address.