HTML5 Interview Questions | Page 3


Question 21:

What is modenizr and What is the use of it in Web development?

As we all know that HTML5 and CSS3 came with cool features, but before using it we must understand that browser implemented prior to HTML5 and CSS3 release does not support them & they are still used by users.

Modernizr is a JavaScript library that detects HTML5 and CSS3 features in the user's browser. 

To add Modernizr, download the file from official page. Then, on your website 's head tag, add a link to the file. For example:

<script src="path/to/modernizr-1.0.min.js"></script>

The second step is to include on your html tag a class "no-js" as shown below:

<html class="no-js">

For example:

<!DOCTYPE html>
<html class="no-js" lang="en">
<head>
	<title>Modernizr - JavaScript Example</title>
	
	<script src="path/to/modernizr.js"></script>
	<script>
		if ( Modernizr.websockets ) {
                        alert("Your browser supports WebSockets");
		} else {
			alert("Your browser does not supports WebSockets");
		}
	</script>
</head>
<body>
	Modernizr - Example
</body>
</html>
Question 22:

What do you mean by sessionStorage in HTML5?

The sessionStorage property allows you to access a session Storage object. sessionStorage is similar to Window.localStorage, the only difference is while data stored in localStorage has no expiration set whereas data stored in sessionStorage gets cleared when the page session ends. A page session lasts for as long as the browser is open and survives over page reloads and restores.

Question 23:

What do you mean by local storage in HTML5?

OR,

What is the difference between local storage and cookies?

Prior to HTML5, if you want to store data locally on user's browser, you have to use cookies. But cookies have their own limitations like:

  • Cookies are included with every HTTP request made to server which degrades the response time.
  • As cookies are sent with HTTP request they can be intercepted over network by hackers.
  • You can store up to 4KB of data in cookies.

Due to this limitations, HTML5 came up with new solution i.e. local storage which can store large amount of data locally & is not transferred to server. 

Local storage provides two objects for storage: 

  • window.localStorage
  • window.sessionStorage 
Question 24:

What is difference between session storage and local storage?

Local storage provides two objects for storage: 

  • window.localStorage
  • window.sessionStorage 

The data stored in localStorage has no expiration set and lasts even after the browser is closed and reopened whereas data stored in sessionStorage gets cleared when the page session ends. A page session lasts for as long as the browser is open and survives over page reloads and restores.

Question 25:

What do you understand by "Web Workers"?

Do you know JavaScript runs in a single-threaded environment? Yes, JavScript runs in single-threaded environment which means that we cannot run two scripts on webpage at a time.

Now assume any webpage which requires some calculation intense logic on webpage when any button is clicked. If the button is clicked the script starts executing and all other controls on webpage is blocked until the script completes execution. To overcome such situation HTML5 introduced Web Workers.

A worker is an object created using a constructor (e.g. Worker()) that runs a named JavaScript file - in the background, independently of other scripts, without affecting the performance of the page. Workers run in another global context that is different from the current window which makes possible to run scripts concurrently on webpage.


Question 26:

What is "audio" tag in HTML5?

The audio tag was introduced in HTML5. This tag is used to add music and other audio streams to your web page and prior to HTML5 if you want to add audio/music on your web page you have to use flash or any other plug-in. 

Currently, <audio> tag supports 3 file formats i.e. MP3, Wav, and Ogg

Question 27:

What is "video" tag in HTML5?

The video tag was introduced in HTML5. This tag is used to add video to your web page and prior to HTML5 if you want to add video on your web page you have to use flash or any other plug-in. 

Currently, <video> tag supports 3 file formats i.e. MP4, WebM, and Ogg

Question 28:

What should you use while web designing SVG or JPEG/GIF?

There are several advantages of using SVG over JPEG/GIF which is listed below:

  • As we all know SVG graphics are created using mathematical formula which means it requires less data and time while loading the web page and SVG consume less bandwidth as compared to JPEG/GIF.
  • SVG images are rendered by the browser and can be changed programmatically which provides the capability making them especially suited for data-driven applications, such as charts. Example: Google Analytics, Google Webmasters and other data-driven application use it.
  • The source file for an SVG image is a text-based file, so is accessible/readable to search engine.
Share interview questions

Comments

Comments
comments powered by Disqus

Navigation

Social Media