HTML5 Interview Questions Part 4
16. What is Web SQL Database in HTML5? Answer:
Web SQL database is not a part of the HTML5 specification but it is a separate specification which introduces a set of APIs to manipulate client-side databases using SQL.
Following are the three methods of Web SQL database,
With the help of openDatabase method, you can create an object for the database.
To create and open the database, you need to use the following syntax,
var dbObj = OpenDatabase('[Database_Name]', '[Version_Number]', '[Text_Description]', '[size]', '[Creation_Callback]')
A transaction method gives us the ability to control a transaction and performing either commit or rollback based on the situation.
The executeSql method is used to execute actual SQL query.
17. Why should we use IndexedDB?Answer:
IndexedDB is an API that allows a user to store large amount of data in the browser and it is more powerful and efficient than Web SQL.
Most of the browsers like Mozilla do not support Web SQL. The use of Web SQL is obsolete and deprecated and not recommended to use in your application, so this is also a limitation of Web SQL.
IndexedDB stores the data as Key-Pair values and can access the data from the same domain.
It is mostly asynchronous and is not a structured query language.
18. What is Modernizr in HTML5?Answer:
It is designed to detect HTML5 and CSS3 features in various browsers. Its main purpose is to provide this feature detection in a complete and standardized manner, so that you can take corresponding action. For example, if a browser does not support video feature then you would like to display a simple page.
19. What is the purpose of Language attribute in HTML5?Answer:
Language attribute is important for accessibility applications (screen readers) and search engines.
The language is declared in Language attribute and the document language can be declared in the <HTML> tag.
20. What is WebSocket API?Answer:
WebSocket is a rich communication protocol that provides full-duplex communication channels over a single TCP connection.
It makes interactive communication session between the user's browser and a server.
Using WebSocket API, you can send messages to a server and receive event-driven responses without having to poll the server for a reply.