A Guide to Mobile and Web Technology(LAMP)

Archive for the ‘HTML5’ Category

HTML5 Interview Questions

1. What is HTML?
HTML stands for HyperText Markup Language. It is the dominant markup language for creating websites and anything that can be viewed in a web browser. If you want to get some extra bonus points, you can learn the history of HTML and throw in some obscure facts.

2. What is the difference between HTML elements and tags?
HTML elements communicate to the browser how to render text. When surrounded by angular brackets <> they form HTML tags. For the most part, tags come in pairs and surround text.

3. What is “Semantic HTML?”
Semantic HTML is a coding style where the tags embody what the text is meant to convey. In Semantic HTML, tags like <b></b> for bold, and <i></i> for italic should not be used, reason being they just represent formatting, and provide no indication of meaning or structure. The semantically correct thing to do is use <strong></strong> and <em></em>. These tags will have the same bold and italic effects, while demonstrating meaning and structure (emphasis in this case).

4. What does DOCTYPE mean?
The term DOCTYPE tells the browser which type of HTML is used on a webpage. In turn, the browsers use DOCTYPE to determine how to render a page. Failing to use DOCTYPE or using a wrong DOCTYPE may load your page in Quirks Mode. See example:
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN” “http://www.w3.org/TR/html4/loose.dtd”&gt;.

5. What’s the difference between standards mode and quirks mode?
Quirks Mode is a default compatibility mode and may be different from browser to browser, which may result to a lack of consistency in appearance from browser to browser.

6. What are the limitations when serving XHTML pages?
Perhaps the biggest issue is the poor browser support XHTML currently enjoys. Internet Explorer and a number of other user agents cannot parse XHTML as XML. Thus, it is not the extensible language it was promised to be. There are many other issues. Take your pick.

7. How many HTML tags are should be used for the most simple of web pages?
Total tags needed is 8. 4 pairs of tags.
<TITLE>Simplest page ever!</TITLE>
Doesn’t get simpler than this.

8. How do you make comments without text being picked up by the browser?
Comments are used to explain and clarify code or to prevent code from being recognized by the browser. Comments start with “*<!–” and end with ” –>“.
<!-- Insert comment here. -->

9. What is the difference between linking to an image, a website, and an email address?
To link an image, use <img> tags. You need specify the image in quotes using the source attribute, src in the opening tag. For hyperlinking, the anchor tag, <a>, is used and the link is specified in the href attribute. Text to be hyperlinked should be placed between the anchor tags. Little known fact: href stands for “hypertext reference.” When linking to an email, the href specification will be “mailto:send@here.com.” See examples below:
<img src=”HTMLrocks.jpg”></img>
<a href=”skilprelaunch2.wpengine.com”>Skilledup</a>
<a href=”brad@skilledup.com”>Email Me</a>

10. My hyperlink or image is not displaying correctly, what is wrong with it?
It could be any number of things, but the most common mistakes are leaving out a tag bracket or quote missing for href, src, or alt text may be the issue. You should also verify the link itself.

11. What is the syntax difference between a bulleted list and numbered list?
Bulleted lists use the <ul> tag, which stands for “unordered,” whereas <ol> is used to create an ordered list.

12. What is the difference between <div> and <frame>?
A <div> is a generic container element for grouping and styling, whereas a <frame> creates divisions within a web page and should be used within the <frameset> tag. The use of <frame> and <frameset> are no longer popular and are now being replaced with the more flexible <iframe>, which has become popular for embedding foreign elements (ie. Youtube videos) into a page.

13. What is the difference between the application model of HTML and HTML5?
Trick question, there is no difference. HTML5 is a continuum of HTML and just a souped up version of the original HTML. There has been no major paradigm shift.

14. What is the difference between HTML and HTML5?
Ans: HTML5 is an upgraded version of HTML. HTML5 comes with lot of new features like Video, Audio/mp3, date select function, placeholder, Canvas, 2D/3D Graphics and Local SQL Database which were not available in previous HTML versions.

15. What is the <!DOCTYPE> ? Is it necessary to use in HTML5?
Ans: The <!DOCTYPE> is an instruction to the web browser about what version of HTML the page is written in.
The <!DOCTYPE> tag does not have an end tag and It is not case sensitive.
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).

16. How many New Markup Elements you know in HTML5
Ans: Below are the New Markup Elements added in HTML5
Tag Description
<article> Specifies independent, self-contained content, could be a news-article, blog post, forum post, or other articles which can be distributed independently from the rest of the site.
<aside> For content aside from the content it is placed in. The aside content should
be related to the surrounding content
<bdi> For text that should not be bound to the text-direction of its parent elements
<command> A button, or a radiobutton, or a checkbox
<details> For describing details about a document, or parts of a document
<summary> A caption, or summary, inside the details element
<figure> For grouping a section of stand-alone content, could be a video
<figcaption> The caption of the figure section
<footer> For a footer of a document or section, could include the name of the author, the
date of the document, contact information, or copyright information
<header> For an introduction of a document or section, could include navigation
<hgroup> For a section of headings, using <h1> to <h6>, where the largest is the main
heading of the section, and the others are sub-headings
<mark> For text that should be highlighted
<meter> For a measurement, used only if the maximum and minimum values are known
<nav> For a section of navigation
<progress> The state of a work in progress
<ruby> For ruby annotation (Chinese notes or characters)
<rt> For explanation of the ruby annotation
<rp> What to show browsers that do not support the ruby element
<section> For a section in a document. Such as chapters, headers, footers, or any
other sections of the document
<time> For defining a time or a date, or both
<wbr> Word break. For defining a line-break opportunity.

17. What are the New Media Elements in HTML5? Is canvas element used in HTML5?
Ans: 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
For embedded content, such as a plug-in
<track> For text tracks used in mediaplayers
we can use Canvas element in html5 like <canvas></canvas>

18. What elements have disappeared in HTML5?
<frame> and <frameset> have been eliminated. Other elements that are no longer supported include: <noframe>, <applet>, <bigcenter> and <basefront>.

19. Do you know New Input Type Attribute in HTML5?
Ans: we can use below new input type Attribute in HTML5
Type Value
tel The input is of type telephone number
search The input field is a search field
url a URL
email One or more email addresses
datetime A date and/or time
date A date
month A month
week A week
time The input value is of type time
datetime-local A local date/time
number A number
range A number in a given range
color A hexadecimal color, like #82345c
placeholder Specifies a short hint that describes the expected value of an input field

20. How to add video and audio in HTML5
Ans: Like the code given below we can add Video in html5
<video width=“320″ height=“240″ controls=“controls”>
<source src=“mysong.mp4″ type=“video/mp4″ />
<source src=“mysong.ogg” type=“video/ogg” />
And Audio like this
<audio controls=“controls”>
<source src=“mysong.ogg” type=“audio/ogg” />
<source src=“mysong.mp3″ type=“audio/mpeg” /> </audio>

21. What is the use of localStorage in HTML5?
Ans: Before HTML5 Local Storage was done with cookies. Cookies are not very good for large amounts of data, because they are passed on by every request to the server, so it was very slow and in-effective.
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 website’s performance. 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


localStorage.address=“Newyork USA”;

22. What is the sessionStorage Object in html5 ? How to create and access?
Ans: 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


23. What are the new image elements in HTML5?
Canvas and WebGL. <Canvas> is a new element that acts as a container for graphical elements like images and graphics. Coupled with JavaScript, it supports 2D graphics. WebGL stands for Web Graphics
Language, a free cross-platform API that is used for generating 3D graphics in web browsers.

24. What is the difference between SVG and <Canvas>?
<Canvas> is an element that manipulates two-dimensional (2D) pixels while Scalable Vector Graphics works in 2D and three-dimensional (3D) vectors. Essentially, <Canvas> is to SVG as Photoshop is to

25. What are data- attributes good for?
The HTML5 data- attribute is a new addition that assigns custom data to an element. It was built to store sensitive or private data that is exclusive to a page or application, for which there are no other matching
attributes or elements.

26. What is the difference between HTML5 interaction in Sencha and Twitter/Bootstrap?
Sencha and Twitter/Bootstrap are both HTML development frameworks that integrate HTML5, CSS3, and JavaScript. The major difference is that in Sencha, the three languages are all comingled together in code, whereas in Bootstrap, HTML and CSS and decoupled.

27. What purpose do Work Workers serve and what are some of their benefits?
Web Workers are background scripts that do not interfere with the user interface or user interactions on a webpage, allowing HTML to render uninterrupted while JavaScript works in the background.

28. Describe the difference between cookies, sessionStorage, and localStorage.
Cookies are small text files that websites place in a browser for tracking or login purposes. Meanwhile, localStorage and sessionStorage are new objects, both of which are storage specifications but vary in scope
and duration. Of the two, localStorage is permanent and website-specific whereas sessionStorage only lasts as long as the duration of the longest open tab.

29. What are some of the major new API’s that come standard with HTML5?
To name a few: Media API, Text Track API, Application Cache API, User Interaction, Data Transfer API, Command API, Constraint Validation API, and the History API.

30. What is the difference in caching between HTML5 and the old HTML?
An important feature of HTML5 is the Application Cache. It creates an offline version of a web application. and stores website files such as HTML files, CSS, images, and JavaScript, locally. It is a feature that
speeds up site performance.

31. What is the difference between inline-block and inline-table?
Display-table will make your tag behave like a table. inline-table just mean that The element is displayed as an inline-level table. You can then do table-cell that let your element behave like a <td> element.
Display-inline – displays your element as an inline element (like <span>), and inline-block will just group them together in a block container.

32. What the use of Canvas Element in HTML5?
Ans: The canvas element is used to draw graphics images on a web page by using javascript like below
<canvas id=“pcdsCanvas” width=“500″ height=“400″>

var pcdsCanvas=document.getElementById(“phpzagCanvas”);
var pcdsText=pcdsCanvas.getContext(“2d”);

33. What purpose does HTML5 serve?
Ans: HTML5 is the proposed next standard for HTML 4.01, XHTML 1.0 and DOM Level 2 HTML. It aims to reduce the need for proprietary plug-in-based rich internet application (RIA) technologies such as Adobe Flash, Microsoft Silverlight, Apache Pivot, and Sun JavaFX.

34. What is the difference between HTMl5 Application cache and regular HTML browser cache?
Ans: 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 site’s performance, though you are of course using bandwidth to download those files initially.

HTML5 offers two new objects for storing data on the client:
LocalStorage – stores data with no time limit


SessionStorage – stores data for one session.The data is deleted when the user closes the browser window.


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

a) Cleaner markup
b) Additional semantics of new elements like <header>, <nav>, and <time>
c) New form input types and attributes that will (and in Opera’s case, do) take the hassle out of scripting forms.

Ans: 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.[1] As of March 2010[update], the specification is in the Draft Standard state at the WHATWG, and in Working Draft state at the W3C.
39. Explain some 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

40. What does a <hgroup> tag do?
Ans : The <hgroup> tag is used to group heading elements.
The <hgroup> element is used to group a set of <h1> to <h6> elements.
<h2>How r u?</h2>

41. What is the major improvement with HTML5 in reference to Flash?
Flash is not supported by major mobile devices such as iPad, iPhone and universal android applications. Those mobile devices have lack of support for installing flash plugins. HTML5 is supported by all the devices, apps and browser including Apple and Android products. Compared to Flash, HTML5 is very secured and protected. That eliminates major concerns that we have seen with Flash.