Realtime HTML Interview Questions And Answers

11. Which methods are used to draw a straight line on a Canvas?
Following methods are used to draw a straight line on a Canvas:
- moveTo(x,y) – It defines the starting co-ordinates of the line
- lineTo(x,y) – It defines the ending co-ordinates of the line
- The actual line is drawn with the help of a method like stroke()

12. What are gradients in Canvas used for? What are their different types?
Gradients in canvas are used to fill rectangles, circles, lines etc.

The gradients in Canvas are of two types:
- createLinearGradient(x,y,x1,y1) – It creates a linear gradient
- createRadialGradient(x,y,r,x1,y1,r1) – It creates a radial/circular gradient

13. Which method is used to draw an image on the canvas?
drawImage(image,x,y) method is used to draw an image on the canvas.

14. HTML 5 provides drag and drop facility. How do you make an image draggable?
To make an image draggable, the draggable attribute is set to true:
<img draggable="true">

15. Can HTML 5 get the geographical position of a user?
- Yes, HTML 5 can get the location of a user with the use of Geolocation API.
- Use getCurrentPosition() method to get the user’s current position.

16. What are the audio tags provided by HTML 5?
HTML 5 provides following audio tags:
<audio> - Defines sound content
<source> - Defines multiple media resources for media elements, such as <video> and <audio>

17. What are the new input types provided by HTML 5 for forms?
Following are the important, new input types for forms provided by HTML 5:
- color – used for fields that should contain colour.
- date – allows the user to select a date
- datetime - allows the user to select a date and time (with time zone)
- datetime-local - allows the user to select a date and time (without time zone)
- email - used for input fields that should contain an e-mail address
- month - allows the user to select a month and year.
- number - used for input fields that should contain a numeric value. Restrictions on type of numbers accepted can be set.
- range - used for input fields that should contain a value from a range of numbers. Restrictions on type of numbers accepted can be set here as well.
- search - used for search fields
- tel - defines a field for entering a telephone number
- time - allows the user to select a time
- url - used for input fields that should contain a URL address
- week - allows the user to select a week and year

18. What is HTML5 Web Storage?
With HTML5, it is possible for the web pages to store the data locally in the user's browser. This web storage is much faster and secured than the cookies. Also, a larger amount of data can be stored without causing any adverse effect to the performance of the website.

The data here is not included with every server request. It is used ONLY when it is asked for. It is only that particular web page that can access the data stored by itself.

19. Differentiate between localStorage and sessionStorage objects.
- localStorage object stores the data without an expiry date while sessionStorage object stores the data only for one session.
- With localStorage object, data will not be deleted when the browser window is closed while the data is deleted when the browser window closes with sessionStorage objects.

20. What is the concept of Application Cache in HTML5? What are its advantages?
The Application Cache concept introduced by HTML5 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 - cached resources load faster
3.Reduced server load - the browser will only download updated/changed resources from the server

Read More Questions:
HTML5 Interview Questions Part1
HTML5 Interview Questions Part2
HTML5 Interview Questions Part3
HTML5 Interview Questions Part4
HTML5 Interview Questions Part5

No comments:

Post a Comment