HTML5 Interview Questions
HTML5 Interview Questions
HTML5 Interview Questions
Code Example:
Advantages:
Advantages of using SVG over other image formats (like JPEG and GIF) are:
SVG images can be created and edited with any text editor
SVG images can be searched, indexed, scripted, and compressed
SVG images are scalable
SVG images can be printed with high quality at any resolution
SVG images are zoomable (and the image can be zoomed without degradation)
SVG is XML based, which means that every element is available within the SVG DOM. You
can attach JavaScript event handlers for an element.
In SVG, each drawn shape is remembered as an object. If attributes of an SVG object are
changed, the browser can automatically re-render the shape.
Canvas is rendered pixel by pixel. In canvas, once the graphic is drawn, it is forgotten by the
browser. If its position should be changed, the entire scene needs to be redrawn, including any
objects that might have been covered by the graphic.
Strict : This DTD contains all HTML elements and attributes, but does NOT INCLUDE
presentational or deprecated elements (like font). Framesets are not allowed.
Transitional : This DTD contains all HTML elements and attributes, INCLUDING
presentational and deprecated elements (like font). Framesets are not allowed.
What is HTML5?
Ans : HTML5 is The New HTML Standard with new elements, attributes, and behaviors.
-
HTML 5 Features:
Ans :
1. The <canvas> element for 2D drawing
2. The <video> and <audio> elements for media playback
3. local storage support.
4. Added New elements, like <figure>,<small>, <header>, <nav>,<article>, <footer>,
<section>,<mark>
5. New form controls, like placeholder,calendar, date, time, email, url, search,required ,autofocus
6. In HTML5 there is only one <!doctype> declaration: <!DOCTYPE html>
-
What is HTML5 Web Storage?
Ans : In HTML5, we can store data locally within the users browser.It is possible to store large
amounts of data without affecting the websites performance.
Web Storage is more secure and faster.
there are two types of Web Storages
1.LocalStorage:stores data locally with no limit
2.SessionStorage:stores data for one session
-
How to store data on client in HTML5?
Ans : we can store data using HTML5 Web Storage.
1.LocalStorage
<script type=text/javascript>
localStorage.name=Raj;
document.write(localStorage.name);
</script>
2.SessionStorage
<script type=text/javascript>
sessionStorage.email=test@gmail.com;
document.write(sessionStorage.email);
</script>
-
How do you play a Video using HTML5?
Example:
<video width=500 height=300 controls>
<source src=video1.mp4 type=video/mp4>
</video>
-
How do you play a Audio using HTML5?
Example:
<audio controls>
<source src=audio.mp3 type=audio/mpeg>
</audio>
-
Canvas Element in HTML5?
Ans : The canvas element is used to draw graphics images on a web page
-
HTML5 <input> Types ?
Ans :
search
tel
time
color
email
month
date
datetime
datetime-local
number
range
url
week
-
HTML5 New Form Attributes?
Ans :
pattern
placeholder
required
step
autocomplete
autofocus
height and width
list
min and max
multiple
form
formaction
formenctype
formmethod
formnovalidate
formtarget
-
What does a <hgroup> tag do?
<hgroup>
<h1>Hello</h1>
<h2>How r u?</h2>
</hgroup>
-
Which video formats are used for the video element?
Ans :
Internet Explorer 9+: MP4
Chrome 6+: MP4, WebM, Ogg
Firefox 3.6+ : WebM, Ogg
Safari 5+ : MP4,
Opera 10.6+ : WebM,Ogg
-
Difference between HTML4 and HTML5
-
What is the <!DOCTYPE> ? Is it necessary to use in HTML5 ?
Ans : The <!DOCTYPE> declaration must be the very first thing in HTML5 document, before
the <html> tag
-
What are the New Media Elements in HTML5?
Ans :
<audio>
<video>
<source>
<track>
1 :: What is the status of the development of the HTML 5 standard?
HTML5 is being developed as the next major revision of HTML (HyperText Markup Language),
the core markup language of the World Wide Web. The Web Hypertext Application Technology
Working Group (WHATWG) started work on the specification in June 2004 under the name
Web Applications 1.0. As of March 2010, the specification is in the Draft Standard state at the
WHATWG, and in Working Draft state at the W3C.
2 :: What are the new APIs provided by the HTML 5 standard? Give a brief description of
each
The canvas element: Canvas consists of a drawable region defined in HTML code with height
and width attributes. JavaScript code may access the area through a full set of drawing functions
similar to other common 2D APIs, thus allowing for dynamically generated graphics. Some
anticipated uses of the canvas include building graphs, animations, games, and image
composition.
Timed media playback
Offline storage database
Document editing
Drag-and-drop
Cross-document messaging
Browser history management
MIME type and protocol handler registration
6 :: WHAT IS HTML5?
HTML5 is the latest version of HTML standard supporting multimedia and graphical content.
1
<script type=text/javascript>
localStorage.lastname=ZAG;
document.write(localStorage.lastname);
</script>
SessionStorage stores data for one session.The data is deleted when the user closes the browser
window.
<script type=text/javascript>
sessionStorage.lastname=ZAG;
document.write(sessionStorage.lastname);
</script>
<audio controls=controls>
<source src=test.mp3 type=audio/mp3 />
</audio>
12 :: What is the difference between HTMl5 Application cache and regular HTML browser
cache?
HTML5 specification allows browsers to prefetch some or all of a website assets such as HTML
files, images, CSS, JavaScript, and so on, while the client is connected. It is not necessary for the
user to have accessed this content previously, for fetching this content. In other words,
application cache can prefetch pages that have not been visited at all and are thereby unavailable
in the regular browser cache. Prefetching files can speed up the sites performance, though you
are of course using bandwidth to download those files initially.
15 :: Do you know What is the sessionStorage Object in html5? How to create and access?
The sessionStorage object stores the data for one session. The data is deleted when the user
closes the browser window. like below we can create and access a sessionStorage here we
created name as session
<script type=text/javascript>
sessionStorage.name=PHPZAG;
document.write(sessionStorage.name);
</script>
In HTML5, the data is NOT passed on by every server request, but used ONLY when asked for.
It is possible to store large amounts of data without affecting the websites performance.and The
data is stored in different areas for different websites, and a website can only access data stored
by itself.
And for creating localstores just need to call localStorage object like below we are storing name
and address
<script type=text/javascript>
localStorage.name=PHPZAG;
document.write(localStorage.name);
</script>
<script type=text/javascript>
localStorage.address=Newyork USA;
document.write(localStorage.address);
</script>
<audio controls=controls>
<source src=mysong.ogg type=audio/ogg />
<source src=mysong.mp3 type=audio/mpeg />
</audio>
19 :: Explain What are the New Media Elements in HTML5? is canvas element used in
HTML5
Below are the New Media Elements have added in HTML5
Tag Description
<audio> For multimedia content, sounds, music or other audio streams
<video> For video content, such as a movie clip or other video streams
<source> For media resources for media elements, defined inside video or audio
elements
For embedded content, such as a plug-in
<track> For text tracks used in mediaplayers
The <!DOCTYPE> declaration must be the very first thing in HTML5 document, before the
<html> tag. As In HTML 4.01, all <! DOCTYPE > declarations require a reference to a
Document Type Definition (DTD), because HTML 4.01 was based on Standard Generalized
Markup Language (SGML). WHERE AS HTML5 is not based on SGML, and therefore does not
require a reference to a Document Type Definition (DTD).