InterviewSolution
This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.
| 1. |
Explain Web Components and it’s usage. |
|
Answer» These are used to create reusable custom elements which are very difficult in traditional HTML. It consists of three technologies:
Here 2 custom elements are defined <open-shadow> and <closed-shadow> which takes their text content and inserts them into a shadow DOM as content of a <p> element.
Here we are reusing the <my-paragraph> template. References:Additional Resource
|
|
| 2. |
Write HTML5 code to demonstrate the use of Geolocation API. |
|
Answer» <!DOCTYPE html><html> <body> <P>Click "try it" button to get your coordinates.</p> <button onclick="getLocation()">Try It</button> <p id="demo"></p> <script> var x = document.getElementById("demo"); function getLocation() { if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(showPosition); } else { x.innerHTML = "Geolocation functionality is not supported by this browser."; } } function showPosition(position) { x.innerHTML = "Latitude: " + position.coords.latitude + "<br>Longitude: " + position.coords.longitude; } </script> </body></html> The above example asks for user PERMISSION for accessing the location data VIA geolocation API and after CLICKING the button the coordinates of the physical location of the client get displayed. |
|
| 3. |
What is the Geolocation API in HTML5? |
|
Answer» Geolocation API is used to SHARE the physical LOCATION of the CLIENT with websites. This helps in serving locale-based content and a unique EXPERIENCE to the user, based on their location. This works with a new property of the GLOBAL navigator object and most of the modern browsers support this. var geolocation = navigator.geolocation; |
|
| 4. |
What is a manifest file in HTML5? |
|
Answer» The manifest file is used to list down RESOURCES that can be cached. Browsers use this information to make the web page load faster than the first time. There are 3 sections in the manifest file
|
|
| 5. |
What are different approaches to make an image responsive? |
Answer»
Bigger Screen (>650px) For any other screen
For example SVG <svg width="100" height="100"> <circle cx="50" cy="50" r="40" STROKE="green" stroke-width="4" fill="YELLOW" /></svg> |
|
| 6. |
How to support SVG in old browsers? |
|
Answer» To SUPPORT old BROWSERS instead of defining the resource of svg in src attribute of <img> tag, it should be defined in srcset attribute and in src the fallback PNG file should be defined. <img src="circle.png" ALT="circle" srcset="circle.svg"> |
|
| 7. |
What are raster images and vector images? |
|
Answer» Raster Images - The raster image is defined by the arrangement of pixels in a grid with exactly what COLOR the pixel should be. Few raster file FORMATS INCLUDE PNG(.png), JPEG(.jpg), etc. |
|
| 8. |
What is the usage of a novalidate attribute for the form tag that is introduced in HTML5? |
|
Answer» Its value is a boolean type that indicates whether or not the data being submitted by the form will be validated beforehand. By making this false, FORMS can be submitted without VALIDATION which helps users to resume later also. <form ACTION = "" method = "get" novalidate> NAME:<BR><input type="name" name="sname"><br> Doubt:<br><input type="number" name="doubt"><br> <input type="submit" value="Submit"></form> |
|
| 9. |
What are the server-sent events in HTML5? |
|
Answer» The events pushed from the webserver to the BROWSERS are called server-sent events. DOM elements can be continuously updated using these events. This has a major advantage over straight-up polling. In polling, there is a LOT of overhead since every time it is ESTABLISHING an HTTP connection and tearing it down whereas, in server-sent events, there is one long-lived HTTP connection. To use a server-sent EVENT, <eventsource> element is used. The src attribute of this element specifies the URL from which sends a data stream having the events. <eventsource src = "/cgi-bin/myfile.cgi" /> |
|
| 10. |
Why do we need the MathML element in HTML5? |
|
Answer» MathML stands for Mathematical Markup Language. It is used for displaying mathematical expressions on WEB PAGES. For this <math> tag is used. <!DOCTYPE HTML><html> <head> </head> <body><math> <mrow> <mrow> <msup> <mi> a </mi> <MN> 2 </mn> </msup> <mo> + </mo> <msup> <mi> b </mi> <mn> 2 </mn> </msup> <mo> + </mo> <mn> 2 </mn> <mn> a </mn> <mn> b </mn> </mrow> <mo> = </mo> <mn> 0 </mn> </mrow></math> </body></html>This displays the equation a2 + b2 + 2ab = 0. |
|
| 11. |
Why do you think the addition of drag-and-drop functionality in HTML5 is important? How will you make an image draggable in HTML5? |
|
Answer» The drag and drop functionality is a very intuitive way to select local files. This is similar to what most of the OS have copy functionality thus making it very easy for the user to COMPREHEND. Before the NATIVE drag and drop API, this was achievable by writing complex Javascript programming or external FRAMEWORKS like jQuery. To enable this functionality there is a draggable attribute in the <img> tag and need to set ondrop and ondragover attribute to an eventhandler available in scripts. <!DOCTYPE HTML><html> <head> <script> function allowDrop(ev) { ev.preventDefault(); } function drop(ev) { ... } </script> </head> <body> ... <div id="div1" ondrop="drop(event)" ondragover="allowDrop(event)" style="border: 1px SOLID #AAAAAA; width:350px; height: 70px;"></div> <br> <img id="drag1" src="img_logo.gif" draggable="true" width="336" height="69"> ... </body></html> |
|
| 12. |
What are the New tags in Media Elements in HTML5? |
Answer»
|
|
| 13. |
Explain new input types provided by HTML5 for forms? |
|
Answer» Following are the significant new data TYPES offered by HTML5:
|
|
| 14. |
Explain HTML5 Graphics. |
|
Answer» HTML5 supports two kinds of graphics:
Both of the above examples produce this output and represent two different approaches provided by HTML5 to implement graphical aspects in the webpage. |
|
| 15. |
What is new about the relationship between the and tags in HTML5? |
|
Answer» As HTML5 was all about better semantics and ARRANGEMENTS of the tags and elements, the <header> tag specifies the header section of the WEBPAGE. Unlike in previous VERSION there was one <h1> ELEMENT for the entire webpage, now this is the header for one section such as <article> or <section>. According to the HTML5 specification, each <header> element must at least have one <h1> tag. |
|
| 16. |
Which tag is used for representing the result of a calculation? Explain its attributes. |
|
Answer» The <output> tag is used for representing the RESULT of a calculation. It has the following attributes:
The above EXAMPLE looks like |
|
| 17. |
What is Microdata in HTML5? |
|
Answer» It is used to help extract data for site crawlers and search engines. It is basically a group of name-value pairs. The groups are called items, and each name-value pair is a property. Most of the search engines like Google, Microsoft, Yandex, etc follow schema.org VOCABULARY to extract this microdata. <div itemscope itemtype="http://schema.org/SoftwareApplication"> <SPAN itemprop="name">Interviewbit Games</span> - REQUIRES <span itemprop="operatingSystem">ANDROID</span><br> <link itemprop="applicationCategory" href="http://schema.org/GameApplication"/> <div itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating">RATING:<span itemprop="ratingValue">4.6</span> (<span itemprop="ratingCount">8864</span> ratings ) </div> <div itemprop="offers" itemscope itemtype="http://schema.org/Offer">Price: Rs.<span itemprop="price">1.00</span><meta itemprop="priceCurrency" content="INR" /> </div></div>
The above example will be PARSED by Google as |
|
| 18. |
Explain the concept of web storage in HTML5. |
|
Answer» This web storage helps in storing some of the static data in the local storage of the browser so that we do not need to fetch it from the server every time we need it. There is a size limit based on DIFFERENT BROWSERS. This helps in decreasing the load time and a smooth user experience. There are two types of web storage that are used to store data locally in HTML5: |
|
| 19. |
What are the significant goals of the HTML5 specification? |
|
Answer» These were the target area of the HTML5 specs:
|
|
| 20. |
What type of audio files can be played using HTML5? |
|
Answer» HTML5 supports the FOLLOWING THREE types of audio file FORMATS:
|
|
| 21. |
Difference between SVG and Canvas HTML5 element? |
||||||||||
Answer»
|
|||||||||||
| 22. |
Is drag and drop possible using HTML5 and how? |
|
Answer» YES, in HTML5 we can drag and drop an ELEMENT. This can be achieved USING the drag and drop-related events to be used with the element which we want to drag and drop. |
|
| 23. |
What is the difference between tag and tag? |
|
Answer» <progress> tag should be used when we want to show the COMPLETION progress of a task, whereas if we just want a SCALAR measurement within a known range or fraction value. Also, we can specify multiple extra ATTRIBUTES for <METER> tags like ‘FORM’, ‘low’, ‘high’, ‘min’, etc. |
|
| 24. |
Convert the below data into Tabular format in HTML5? |
|
Answer» S.no., LANGUAGE, MOSTLY USED for 1, HTML, FrontEnd 2, CSS, FrontEnd 3, Python, BackEnd |
|
| 25. |
What are Semantic Elements? |
|
Answer» SEMANTIC ELEMENTS are those which describe the particular meaning to the browser and the developer. Elements like <form>, <table>, <ARTICLE>, <FIGURE>, etc., are semantic elements. |
|
| 26. |
Define Image Map? |
|
Answer» IMAGE Map lets a developer map/LINK different parts of images with the different web pages. It can be achieved by the <map> tag in HTML5, using which we can link images with CLICKABLE areas. <img SRC=”image_url” , usemap=”#workspace” /><map name=”workspace”> <area SHAPE=”rect” coords=”34, 44, 270, 350” , href=”xyz.html” /> <area shape=”rect” coords=”10, 120, 250, 360” , href=”xyz.html” /></map> |
|
| 27. |
Is the tag and tag same? |
|
Answer» No. The <datalist> tag and <select> tag are different. In the case of <select> tag a user will have to choose from a LIST of options, whereas <datalist> when used ALONG with the <input> tag provides a suggestion that the user selects one of the options given or can ENTER some ENTIRELY different value. |
|
| 28. |
How to specify the metadata in HTML5? |
|
Answer» To specify we can use <meta> tag which is a void tag,i.e., it does not have a CLOSING tag. Some of the attributes used with meta tags are name, content, http-equiv, ETC. The below IMAGE tells how to specify the METADATA. |
|
| 29. |
What is the difference between tag and tag? |
|
Answer» The <figure> TAG specifies the self-contained content, LIKE diagrams, images, code snippets, etc. <figure> tag is used to SEMANTICALLY organize the contents of an image like image, image caption, etc., whereas the <img> tag is used to embed the picture in the HTML5 document. |
|
| 30. |
Inline and block elements in HTML5? |
||||
Answer»
|
|||||
| 31. |
How can we include audio or video in a webpage? |
|
Answer» HTML5 PROVIDES two TAGS: <audio> and <video> tags using which we can add the audio or video DIRECTLY in the webpage. |
|
| 32. |
What are some of the advantages of HTML5 over its previous versions? |
|
Answer» Some advantages of HTML5 are:-
|
|