Top HTML and HTML5 Interview Questions (2023)

Top HTML and HTML5 – This text covers essentially the most steadily requested HTML and HTML5 questions requested in interviews.

Table of Contents


Top HTML and HTML5 interview questions · 1. Are the HTML tags and elements the same thing? · 2. What are tags and attributes in HTML?- Earlier than beginning with the interview questions on HTML Language, let’s first undergo HTML, what’s HTML, the profession alternatives it offers, and so on.

HTML stands for HyperText Markup language. It’s a commonplace textual content formatting language used for creating internet pages launched in 1993. HTML is a language that’s interpreted by the browser and it tells the browser what to show and the right way to show.

HTML is an necessary language to be taught if anybody desires to work within the internet improvement area [Web designers, Web Developers]. HTML alone will not be enough for a internet developer as a result of HTML solely defines the construction of the information that will probably be rendered on the browser in a webpage, to make it visually interesting and to make it purposeful, we might want to use CSS and Javascript respectively. 

Top HTML and HTML5 Interview Questions and Solutions

1. Are the HTML tags and parts the identical factor?

No. HTML parts are outlined by a beginning tag, could include some content material and a closing tag.For instance, <h1>Heading 1</h1> is a HTML aspect however simply <h1> is a beginning tag and </h1> is a closing tag.

2. What are tags and attributes in HTML?

Tags are the first element of the HTML that defines how the content material will probably be structured/ formatted, whereas Attributes are used together with the HTML tags to outline the traits of the aspect. For instance, <p align=” heart”>Interview questions</p>, on this the ‘align’ is the attribute utilizing which we are going to align the paragraph to point out within the heart of the view.

3. What are void parts in HTML?

HTML parts which wouldn’t have closing tags or don’t must be closed are Void parts. For Instance <br />, <img />, <hr />, and so on.

4. What’s the benefit of collapsing white area?

In HTML, a clean sequence of whitespace characters is handled as a single area character, As a result of the browser collapses a number of areas right into a single area character and this helps a developer to indent strains of textual content with out worrying about a number of areas and keep readability and understandability of HTML codes.

5. What are HTML Entities?

In HTML some characters are reserved like ‘<’, ‘>’, ‘/’, and so on. To make use of these characters in our webpage we have to use the character entities known as HTML Entities. Under are a couple of mapping between the reserved character and its respective entity character for use.

CharacterEntity TitleEntity Quantity
(non-breaking area) Eg. 10  PM&nbsp; Eg. <p>10&nbsp&nbspPM</p>&#160;

6. What are various kinds of lists in HTML?

7. What’s the ‘class’ attribute in HTML?

The category attribute is used to specify the category title for an HTML aspect. A number of parts in HTML can have the identical class worth. Additionally, it’s primarily used to affiliate the types written within the stylesheet with the HTML parts.

8. What’s the distinction between the ‘id’ attribute and the ‘class’ attribute of HTML parts?

A number of parts in HTML can have the identical class worth, whereas a price of id attribute of 1 aspect can’t be related to one other HTML aspect.

9. Outline multipart type knowledge?

Multipart type knowledge is likely one of the values of the enctype attribute. It’s used to ship the file knowledge to the server-side for processing. The opposite legitimate values of the enctype attribute are textual content/plain and software/x-www-form-urlencoded.

10. Describe HTML format construction.

Each internet web page has completely different parts to show the meant content material and a selected UI. However nonetheless, there are few issues that are templated and are globally accepted option to construction the net web page, corresponding to:

  • <header>: Shops the beginning details about the net web page.
  • <footer>: Represents the final part of the web page.
  • <nav>: The navigation menu of the HTML web page.
  • <article>: It’s a set of knowledge.
  • <part>: It’s used contained in the article block to outline the essential construction of a web page.
  • <apart>: Sidebar content material of the web page.

11. Tips on how to optimize web site belongings loading?

To optimize web site load time we have to optimize its asset loading and for that:

  • CDN internet hosting – A CDN or content material supply community is geographically distributed servers to assist cut back latency.
  • File compression – This can be a methodology that helps to scale back the dimensions of an asset to scale back the information switch
  • File concatenation – This reduces the variety of HTTP calls
  • Minify scripts – This reduces the general file dimension of js and CSS information
  • Parallel downloads – Internet hosting belongings in a number of subdomains can assist to bypass the obtain restrict of 6 belongings per area of all fashionable browsers. This may be configured however most basic customers by no means modify these settings.
  • Lazy Loading – As an alternative of loading all of the belongings directly, the non-critical belongings might be loaded on a necessity foundation.

12. What are the varied formatting tags in HTML?

 HTML has numerous formatting tags:

  • <b> – makes textual content daring
  • <i> – makes textual content italic
  • <em> – makes textual content italic however with added semantics significance
  • <large> – will increase the font dimension of the textual content by one unit
  • <small> – decreases the font dimension of the textual content by one unit
  • <sub> – makes the textual content a subscript
  • <sup> – makes the textual content a superscript
  • <del> – shows as strike out textual content
  • <sturdy> – marks the textual content as necessary
  • <mark> – highlights the textual content
  • <ins> – shows as added textual content

13. What are the completely different sorts of Doctypes obtainable?

The three sorts of Doctypes which can be found:

  • Strict Doctype 
  • Transitional Doctype
  • Frameset Doctype

14. Please clarify the right way to point out the character set being utilized by a doc in HTML?

The character set is outlined in <meta> tag inside <head> aspect.

<!DOCTYPE html>
   <meta charset="UTF-8">

15. What’s the distinction between <sturdy>, <b> tags and <em>, <i> tags?

The impact on a traditional webpage of the tags <sturdy>, <b>  and <em>, <i> is similar. <b> and <i> tags stands for daring and italic. These two tags solely apply font styling and daring tag <b>, simply provides extra ink to the textual content, these tags do not say something concerning the textual content.

Whereas, <sturdy> and <em> tags symbolize that the span of textual content is of sturdy significance or extra significance and emphatic stress respectively than the remainder of the textual content. These tags have semantic which means.

16. What’s the significance of <head> and <physique> tag in HTML?

<head> tag offers the details about the doc. It ought to at all times be enclosed within the <html> tag. This tag incorporates the metadata concerning the webpage and the tags that are enclosed by head tag like <hyperlink>, <meta>, <fashion>, <script>, and so on. aren’t displayed on the internet web page. Additionally, there might be just one <head> tag in all the Html doc and can at all times be earlier than the <physique> tag.

<physique> tag defines the physique of the HTML doc. It ought to at all times be enclosed within the <html> tag. All of the contents which must be displayed on the internet web page like photos, textual content, audio, video, contents, utilizing parts like <p>, <img>, <audio>, <heading>, <video>, <div>, and so on. will at all times be enclosed by the <physique> tag. Additionally, there might be just one physique aspect in an HTML doc and can at all times be after the <head> tag.

17. Can we show an online web page inside an online web page or Is nesting of webpages attainable?

Sure, we will show an online web page inside one other HTML internet web page. HTML offers a tag <iframe> utilizing which we will obtain this performance.

<iframe src=”url of the net web page to embed” />

18. How is Cell Padding completely different from Cell Spacing?

Cell Spacing is the area or hole between two consecutive cells. Whereas, Cell Padding is the area or hole between the textual content/ content material of the cell and the sting/ border of the cell. Please consult with the above determine instance to seek out the distinction.

19. How can we membership two or extra rows or columns right into a single row or column in an HTML desk?

HTML offers two desk attributes “rowspan” and “colspan” to make a cell span to a number of rows and columns respectively.

20. Is it attainable to alter an inline aspect right into a block degree aspect?

Sure, it’s attainable utilizing the “show” property with its worth as “block”, to alter the inline aspect right into a block-level aspect.

21. In what number of methods can we place an HTML aspect? Or what are the permissible values of the place attribute?

There are primarily 7 values of place attribute that can be utilized to place an HTML aspect:

  1. static: Default worth. Right here the aspect is positioned in line with the traditional circulate of the doc.
  2. absolute: Right here the aspect is positioned relative to its mum or dad aspect. The ultimate place is decided by the values of left, proper, high, backside.
  3. mounted: That is much like absolute besides right here the weather are positioned relative to the <html> aspect.
  4. relative: Right here the aspect is positioned in line with the traditional circulate of the doc and positioned relative to its unique/ regular place.
  5. preliminary: This resets the property to its default worth.
  6. inherit: Right here the aspect inherits or takes the property of its mum or dad.

22. In what number of methods you’ll be able to show HTML parts?

  1. inline: Utilizing this we will show any block-level aspect as an inline aspect. The peak and width attribute values of the aspect is not going to have an effect on.
  2. block: utilizing this, we will show any inline aspect as a block-level aspect. 
  3. inline-block: This property is much like inline, besides through the use of the show as inline-block, we will truly format the aspect utilizing top and width values.
  4. flex: It shows the container and aspect as a versatile construction. It follows flexbox property.
  5. inline-flex: It shows the flex container as an inline aspect whereas its content material follows the flexbox properties.
  6. grid: It shows the HTML parts as a grid container.
  7. none: Utilizing this property we will disguise the HTML aspect.

Under are a number of the show varieties that are hardly ever used:

  1. desk
  2. inline-table
  3. table-cell
  4. table-column
  5. table-row
  6. inline-grid
  7. list-item
  8. inherit
  9. preliminary
  10. table-caption

23. What’s the distinction between “show: none” and “visibility: hidden”, when used as attributes to the HTML aspect.

After we use the attribute “visibility: hidden” for an HTML aspect then that aspect will probably be hidden from the webpage however nonetheless takes up area. Whereas, if we use the “show: none” attribute for an HTML aspect then the aspect will probably be hidden, and likewise it received’t take up any area on the webpage.

24. Tips on how to specify the hyperlink in HTML and clarify the goal attribute?

HTML offers a hyperlink – <a> tag to specify the hyperlinks in a webpage. The ‘href’ attribute is used to specify the hyperlink and the ‘goal’ attribute is used to specify, the place can we wish to open the linked doc. The ‘goal’ attribute can have the next values:

  1. _self: This can be a default worth. It opens the doc in the identical window or tab because it was clicked.
  2. _blank: It opens the doc in a brand new window or tab.
  3. _parent: It opens the doc in a mum or dad body.
  4. _top: It opens the doc in a full-body window.

25. In what number of methods can we specify the CSS types for the HTML aspect?

There are 3 ways during which we will specify the types for HTML parts:

  • Inline: Right here we use the ‘fashion’ attribute contained in the HTML aspect.
  • Inner: Right here we use the <fashion> tag contained in the <head> tag. To use the fashion we bind the weather utilizing ‘id’ or ‘class’ attributes.
  • Exterior: Right here we use the <hyperlink> tag inside <head> tag to reference the CSS file into our HTML code. Once more the binding between parts and types is finished utilizing ‘id’ or ‘class’ attributes.

26. Distinction between hyperlink tag <hyperlink> and anchor tag <a>?

The anchor tag <a> is used to create a hyperlink to a different webpage or to a sure a part of the webpage and these hyperlinks are clickable, whereas, hyperlink tag <hyperlink> defines a hyperlink between a doc and an exterior useful resource and these aren’t clickable.

27. Tips on how to embody javascript code in HTML?

HTML offers a <script> tag utilizing which we will run the javascript code and make our HTML web page extra dynamic.

<!DOCTYPE html>
          <span>This can be a demo for </span>
          <u><span id="demo"></span></u>
       doc.getElementById("demo").innerHTML = "script Tag"

28. When to make use of scripts within the head and when to make use of scripts within the physique?

If the scripts include some event-triggered capabilities or jquery library then we must always use them within the head part. If the script writes the content material on the web page or will not be inside a operate then it must be positioned contained in the physique part on the backside. Briefly, observe under three factors:

  1. Place library scripts or occasion scripts within the head part.
  2. Place regular scripts that don’t write something on the web page, within the head part till there may be any efficiency difficulty.
  3. Place scripts that render one thing on the internet web page on the backside of the physique part.

29. What are kinds and the right way to create kinds in HTML?

The HTML type is used to gather the consumer inputs. HTML offers a <type> tag to create kinds. To take enter from the consumer we use the <enter> tag inside the shape so that every one collected consumer knowledge might be despatched to the server for processing. There are completely different enter varieties like ‘button’, ‘checkbox’, ‘quantity’, ‘textual content’, ‘password’, ‘submit’ and so on.

<type motion="/submit_data.php">
   <label>Enter your title: </label>
   <enter kind="textual content" title="title" /> 
   <label>Enter Cellular quantity </label>
   <enter kind="quantity" title="mobile_no"/>
   <enter kind="submit" worth="Submit">

30. Tips on how to deal with occasions in HTML?

HTML permits occasion set off actions in browsers utilizing javascript or JQuery. There are quite a lot of occasions like ‘onclick’, ‘ondrag’, ‘onchange’, and so on.

<!DOCTYPE html>
   <physique fashion="padding-top:50px">
       <h3 id="event_demo">0</h3>
       <enter kind="button" onclick="myFunction()" worth="Click on Me" />
       <enter kind="reset" onclick="reset()" worth="Reset" />
       operate myFunction() 
           var worth = doc.getElementById("event_demo").innerHTML
           worth = parseInt(worth) + 1;
           doc.getElementById("event_demo").innerHTML = worth;
       operate reset() 

HTML5 Interview Questions

31. What are a number of the benefits of HTML5 over its earlier variations?

Some benefits of HTML5 are:-

  • It has Multimedia Assist.
  • It has the capabilities to retailer offline knowledge utilizing SQL databases and software cache.
  • Javascript might be run within the background.
  • HTML5 additionally permits customers to attract numerous shapes like rectangles, circles, triangles, and so on.
  • Included new Semantic tags and type management tags.

32. How can we embody audio or video in a webpage?

HTML5 offers two tags: <audio> and <video> tags utilizing which we will add the audio or video instantly within the webpage.

33. Inline and block parts in HTML5?

Inline parts simply take up the area that’s completely crucial for the content material and doesn’t begin from a brand new line.
Instance:- <span>, <a>, <sturdy>, <img>, <button>, <em>, <choose>, <abbr>, <label>, <sub>, <cite>, <abbr>, <script>, <label>, <i>, <enter>, <output>, <q>, and so on.
Block parts begin on a brand new line and eat the total width of the web page obtainable.
Instance:- <div>, <p>, <header>, <footer>, <h1>…<h6>, <type>, <desk>, <canvas>, <video>, <blockquote>, <pre>, <ul>, <ol>, <figcaption>, <determine>, <hr>, <article>, <part>, and so on.

34. What’s the distinction between <determine> tag and <img> tag?

The <determine> tag specifies the self-contained content material, like diagrams, photos, code snippets, and so on. <determine> tag is used to semantically manage the contents of a picture like picture, picture caption, and so on., whereas the <img> tag is used to embed the image within the HTML5 doc.

35. Tips on how to specify the metadata in HTML5?

To specify we will use <meta> tag which is a void tag,i.e., it doesn’t have a closing tag. A number of the attributes used with meta tags are title, content material, http-equiv, and so on. The under picture tells the right way to specify the metadata.

36. Is the <datalist> tag and <choose> tag similar?

No. The <datalist> tag and <choose> tag are completely different. Within the case of <choose> tag a consumer should select from a listing of choices, whereas <datalist> when used together with the <enter> tag offers a suggestion that the consumer selects one of many choices given or can enter some solely completely different worth.

37. Outline Picture Map?

Picture Map lets a developer map/hyperlink completely different elements of photos with the completely different internet pages. It may be achieved by the <map> tag in HTML5, utilizing which we will hyperlink photos with clickable areas.

<img  src=”image_url” ,  usemap=”#workspace” />
<map  title=”workspace”>
     <space form=”rect”  coords=”34, 44, 270, 350” ,  href=”xyz.html” />
     <space form=”rect”  coords=”10, 120, 250, 360” ,  href=”xyz.html” />

38. What are Semantic Components?

Semantic parts are these which describe the actual which means to the browser and the developer. Components like <type>, <desk>, <article>, <determine>, and so on., are semantic parts.

39. Convert the under knowledge into Tabular format in HTML5?, Language, Principally used for

1, HTML, FrontEnd

2, CSS, FrontEnd

3, Python, BackEnd

40. What’s the distinction between <meter> tag and <progress> tag?

<progress> tag must be used after we wish to present the completion progress of a process, whereas if we simply need a scalar measurement inside a recognized vary or fraction worth. Additionally, we will specify a number of further attributes for <meter> tags like ‘type’, ‘low’, ‘excessive’, ‘min’, and so on.

41. Is drag and drop attainable utilizing HTML5 and the way?

Sure, in HTML5 we will drag and drop a component. This may be achieved utilizing the drag and drop-related occasions for use with the aspect which we wish to drag and drop.

42. Distinction between SVG and Canvas HTML5 aspect?

SVG is a vector primarily based i.e., composed of shapes. It’s Raster primarily based i.e., composed of pixels.
SVG works higher with a bigger floor.Canvas works higher with a smaller floor.
SVG might be modified utilizing CSS and scripts.Canvas can solely be modified utilizing scripts.
SVG is very scalable. So we will print at top quality with excessive decision.It’s much less scalable.

43. What kind of audio information might be performed utilizing HTML5?

HTML5 helps the next three varieties of audio file codecs:

  1. Mp3
  2. WAV
  3. Ogg

44. What are the numerous targets of the HTML5 specification?

These had been the goal space of the HTML5 specs:

  • Introduction of latest aspect tags to higher construction the net web page corresponding to <header> tag.
  • Forming an ordinary in cross-browser habits and assist for various gadgets and platforms
  • Backward suitable with the older model HTML internet pages
  • Introduction of primary interactive parts with out the dependency of plugins corresponding to <video> tag as an alternative of the flash plugin.

45. Clarify the idea of internet storage in HTML5.

This internet storage helps in storing a number of the static knowledge within the native storage of the browser in order that we don’t must fetch it from the server each time we’d like it. There’s a dimension restrict primarily based on completely different browsers. This helps in reducing the load time and a easy consumer expertise. There are two varieties of internet storage which can be used to retailer knowledge regionally in HTML5:

  • Native Storage – This helps in storing knowledge that will probably be retained regardless that the consumer reopens the browser. It’s saved for every webapp on completely different browsers.
  • Session Storage – That is used for one session solely. After the consumer closes the browser this will get deleted.

46. What’s Microdata in HTML5?

It’s used to assist extract knowledge for web site crawlers and serps. It’s principally a gaggle of name-value pairs. The teams are known as gadgets, and every name-value pair is a property. Most of the various search engines like Google, Microsoft, Yandex, and so on observe vocabulary to extract this microdata.

<div  >
 <span >Interviewbit Video games</span> -
 REQUIRES <span >ANDROID</span><br>
 <hyperlink  href=""/>
 <div   >
<span >4.6</span> (
<span >8864</span> scores )
 <div   >
Worth: Rs.<span >1.00</span>
<meta  content material="INR" />
  • itemid – The distinctive, international identifier of an merchandise.
  •  – Used so as to add properties to an merchandise.
  • itemref – Gives a listing of aspect ids with extra properties.
  •  – It defines the scope of the related to it.
  •  – Specifies the URL of the vocabulary that will probably be used to outline .

47. Which tag is used for representing the results of a calculation? Clarify its attributes.

The <output> tag is used for representing the results of a calculation. It has the next attributes:

  • for – It defines the connection between the weather utilized in calculation and end result.
  • type – That is used to outline the shape the output aspect belongs to.
  • title – The title of the output aspect.
<type oninput = "end result.worth=parseInt(n1.worth)+parseInt(n2.worth)">
     <enter kind = "quantity" title = "n1" worth = "1" /> +
     <enter kind = "quantity" title = "n2" worth = "2" /><br />
     The output is: <output title = "end result"></output>

The above instance appears like

48. What’s new concerning the relationship between the <header> and <h1> tags in HTML5?

As HTML5 was all about higher semantics and preparations of the tags and parts, the <header> tag specifies the header part of the webpage. In contrast to in earlier model there was one <h1> aspect for all the webpage, now that is the header for one part corresponding to <article> or <part>. Based on the HTML5 specification, every <header> aspect should no less than have one <h1> tag.

49. Clarify HTML5 Graphics.

HTML5 helps two sorts of graphics:

  • Canvas – It’s like drawing on a whitepaper or a clean webpage. We will add completely different graphic designs on internet pages with obtainable strategies for drawing numerous geometrical shapes.
   <canvas width="300" top="100" fashion="border:2px strong;"></canvas>  
  • SVG – Scalable Vector Graphics are used principally for diagrams or icons. It follows the XML format.
<!DOCTYPE html>
   <svg width="400" top="110">
     <rect width="300" top="100" fashion="fill:#FFF;stroke-width:2;stroke:#000" />

Each of the above examples produce this output and symbolize two completely different approaches supplied by HTML5 to implement graphical points within the webpage.

50. Clarify new enter varieties supplied by HTML5 for kinds?

Following are the numerous new knowledge varieties supplied by HTML5:

  • Date – Solely choose date through the use of kind = “date”
  • Week – Decide every week through the use of kind = “week”
  • Month – Solely choose month through the use of kind = “month”
  • Time – Solely choose time through the use of kind = “time”.
  • Datetime – Mixture of date and time through the use of kind = “datetime”
  • Datetime-local – Mixture of  date and time through the use of kind = “datetime-local.” however ignoring the timezone
  • Coloration – Accepts a number of colours utilizing kind = “shade”
  • E mail – Accepts a number of e mail addresses utilizing kind = “e mail”
  • Quantity – Accepts a numerical worth with extra checks like min and max utilizing kind = “quantity”
  • Search – Permits looking queries by inputting textual content utilizing kind = “search”
  • Tel – Permits completely different telephone numbers through the use of kind = “tel”
  • Placeholder – To show a brief trace within the enter fields earlier than getting into a price utilizing kind = “placeholder”
  • Vary – Accepts a numerical worth inside a selected vary utilizing kind = “vary”
  • Url – Accepts an online tackle utilizing kind = “url”
            <enter kind="date" id="date" />
            <enter kind="week" id="week" />
            <enter kind="month" id="month" />
            <enter kind="time" id="time" />
            <enter kind="datetime" id="datetime" />
            <label>Datetime Native:</label>
            <enter kind="datetime-local" id="datetime-local" />
            <enter kind="shade" id="shade"/>
            <label>E mail:</label>
            <enter kind="e mail" id="e mail" placeholder="e mail tackle" />
            <enter kind="quantity" id="quantity" />
            <enter kind="search" id="search" />
            <enter kind="tel" id="telephone" placeholder="Cellphone Quantity" sample="\d{10}$" />
            <enter kind="vary" id="vary" />
            <enter kind="url" id="url"/>

51. What are the New tags in Media Components in HTML5?

  • <audio> – Used for sounds, audio streams, or music, embed audio content material with none extra plug-in.
  • <video> – Used for video streams, embed video content material and so on.
  • <supply> – Used for a number of media assets in media parts, corresponding to audio, video, and so on.
  • <embed> – Used for an exterior software or embedded content material.
  • <monitor> – Used for subtitles within the media parts corresponding to video or audio.
    <video width="320" top="240" controls>
        <supply src="video.mp4" kind="video/mp4">
        <monitor src="subtitles.vtt" sort="subtitles" srclang="en" label="English">
    <embed kind="video/webm" src="" width="400" top="300">
    <audio controls>
        <supply src="audio.mp3" kind="audio/mpeg">

Leave a Reply

Your email address will not be published. Required fields are marked *