Home >> Interviews Q & A >> HTML5 Interview Questions and Answers

HTML5 Interview Questions and Answers

HTML5 Interview Questions: HTML5 Interview Questions and Answers for freshers and experienced. HTML5 is a markup language used for structuring and presenting content on the World Wide Web.
What is HTML5?

HTML5 is the latest version of Hypertext Markup Language, the code that describes web pages.

It's actually three kinds of code:
  • HTML, which provides the structure
  • Cascading Style Sheets (CSS), which take care of presentation
  • JavaScript, which makes things happen
What is file extension of HTML5?
.html
What is the correct syntax for Doctype in HTML5?

Latest syntax for HTML5 document type is now <!DOCTYPE html> only

It is not a HTML tag but instructs the browser about the version of the HTML being used.

It is not case sensitive

What are the key differences between HTML4 and HTML5?
HTML5 is more power full and easier than Html4, It have lot of new tags like header, footer, nav, audio, video, main etc. It also supports graphics etc.
HTML HTML5
Doctype declaration in Html is too longer
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
DOCTYPE declaration in HTML5 is very simple "<!DOCTYPE html>
character encoding in Html is also longer
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
character encoding (charset) declaration is also very simple <meta charset="UTF-8">
Audio and Video are not part of HTML4 Audio and Videos are integral part of HTML5 e.g. <audio> and <video> tags.
Vector Graphics is possible with the help of technologies such as VML, Silverlight, Flash etc Vector graphics is an integral part of HTML5 e.g. SVG and canvas
It is almost impossible to get true GeoLocation of user browsing any website especially if it comes to mobile devices. JS GeoLocation API in HTML5 helps identify location of user browsing any website (provided user allows it)
HTML5 use cookies. It provides local storage in place of cookies.
Not possible to draw shapes like circle, rectangle, triangle. Using HTML5 you can draw shapes like circle, rectangle, triangle.
Does not allow JavaScript to run in browser. JS runs in same thread as browser interface. Allows JavaScript to run in background. This is possible due to JS Web worker API in HTML5
Works with all old browsers Supported by all new browser.
What are the various tags provided for better structuring in HTML5?
  1. <article> - This tag defines an article.
  2. <aside> - It defines content other than the page content.
  3. <bdi> - This tag isolates a part of text for formatting in a different direction from other text.
  4. <command> - It defines a command button to be invoked by the user.
  5. <details> - It defines additional details that can be viewed or hidden by the user.
  6. <dialog> - It defines a dialog box.
  7. <figure> - This tag specifies content like illustrations, diagrams, photos, code listings, etc.
  8. <figcaption> - It is used to provide a caption for a <figure> element
  9. <footer> - This tag defines a footer for a document or section
  10. <header> - This tag is used to define a header for a document or section
  11. <hgroup> -When there are multiple levels in a heading, it groups a set of <h1> to <h6> elements.
  12. <mark> - It defines highlighted text.
  13. <meter> - It defines a scalar measurement within a known range.
  14. <nav> - It defines links for navigation.
  15. <progress> - This tag exhibits the progress of a task.
  16. <ruby> - It defines a ruby annotation for East Asian typography.
  17. <rt> - It defines an explanation/pronunciation of characters for East Asian typography.
  18. <rp> - This tag tells the system what to display in browsers that do not support ruby annotations.
  19. <section> - It defines a section in a document.
  20. <summary> - It provides a visible heading for a <details> element.
  21. <time> - This tag defines a date/time.
  22. <wbr> - This tag defines a line-break.
What are the new features in HTML5?
Following are some new features in HTML5
  • Local storage.
  • New form controls like calendar, date, time, email, URL and search etc.
  • canvas element is provided for 2D drawing.
  • video and audio elements for media playback.
  • New elements are provided. For e.g. article, header, footer, nav, section.
What is SVG?

SVG stands for Scalable Vector Graphics.

  • SVG is used to define vector-based graphics for the Web
  • SVG defines the graphics in XML format
  • SVG graphics do NOT loose any quality if they are zoomed or resized
  • Every element and every attribute in SVG files can be animated
  • SVG is an W3C standard
SVG Circle:

  

What are the different types of storage in HTML 5?

HTML 5 has the capability to store data locally.

Previously it was done with the help of cookies.

Exciting thing about this storage is that its fast as well as secure

There are two different objects which can be used to store data.
  • localStorage object stores data for a longer period of time even if the browser is closed.
  • sessionStorage object stores data for a specific session.
sessionStorage localStorage
It persists data until we close the window or tab in which it was stored. It persist data even if the window or tab is closed (but can be explicitly removed or expires).
Values stored in sessionStorage are not shared. These will be visible only to respective window or tab. Values stored in localStorage are shared for all windows and tabs from same origin.
Maximum size is 5MB. Maximum size for localStorage is more between 10-15MB.
Working with localStorage is quite simple and having following methods:
  • localStorage.getItem(key): fetch an item from storage against provided key.
  • localStorage.setItem(key, value): add an item to storage.
  • localStorage.removeItem(key): removes an item from storage against provided key.
  • localStorage.clear(): clearing the storage removing all items from it.
What are the deprecated Elements in HTML5?
  • frame
  • frameset
  • noframe
  • applet
  • big
  • acronym
  • basefont
  • center
What is canvas in HTML5?

HTML5 introduce new tag canvas which is used to draw graphics on the web page. It draw graphics on web by using JavaScript.

canvas is only a container for graphics you must need to write a script to draw graphics on web page.

What is the difference between Canvas and SVG graphics?
The HTML5 introduced the two graphical elements Canvas and SVG for creating rich graphics on the web, but they are fundamentally different
SVG Canvas
Vector based (composed of shapes) Raster based (composed of pixel)
Multiple graphical elements, which become the part of the DOM Single HTML element similar to <img> in behavior
Modified through script and CSS Modified through script only
Give better performance with smaller number of objects or larger surface, or both Give better performance with smaller surface or larger number of objects, or both
Better scalability — can be printed with high quality at any resolution Poor scalability — not suitable for printing on higher resolution
What are web workers and why do we need them ?

A web worker is a JavaScript running in the background, without affecting the performance of the page.

What are the restrictions of Web Worker thread?

One limitation is that Web Workers cannot access the DOM, so they can't read or modify the HTML document

Since web workers are in external files, they do not have access to the following JavaScript objects:
  • The window object
  • The document object
  • The parent object
How to terminate a web worker?
The terminate() method of the Worker interface immediately terminates the Worker
var myWorker = new Worker('worker.js');
myWorker.terminate();
What is HTML5 Server-Sent Events?

Server-Sent Events allow a web page to get updates from a server.

What is the concept of Application Cache in HTML5? What are its advantages?

HTML5 introduced a new concept Application Cache - means that a web application is cached, and accessible without an internet connection.

There are three advantages of Application Cache:

  1. Offline browsing - Users can use the application when they're offline
  2. Speed/Improve performance - Cached resources load faster
  3. Reduce HTTP request and server load - The browser will only download updated/changed resources from the server

The HTML5's application cache feature is supported in all major modern browsers like Firefox, Chrome, Opera, Safari and Internet Explorer 10+.

What is a Manifest file?

A Manifest file is a simple text file that tells the browser what to cache and what not to cache.

To enable the application cache for an application, you must include the manifest attribute in the <html> element in your application's pages

There are three sections of a Manifest file:

  1. CACHE MANIFEST - Files listed here are cached after they are downloaded for the first time.
  2. NETWORK - Files listed here require a connection to the server, and are never cached.
  3. FALLBACK - Files listed here specify fallback pages if a page is inaccessible.
Full Stack Tutorials

Author | Blogger @FullStackTutorials | View all articles