Most Important HTML Interview Questions & Answers

HTML is the most fundamental and versatile language. If you are a fresher or a professional in web development, HTML should be one of the skills under your belt. Interviewers often seek candidates with firm HTML basics and therefore you should be well prepared with every possible interview question.

Top HTML Interview Questions And Answers

This article walks you through the most important HTML interview questions ranging from basic to intermediate and advanced levels. We have covered the latest topics from HTML and HTML5.

1. What is HTML?

HTML or HyperText Markup Language is used to create the basic structure of any webpage. HTML is itself capable of making a simple static website without the use of any additional languages.

2. How to Set Background Images in HTML?

In HTML, the 'background' attribute can be used to insert an image into the webpage. This attribute is added with the body tag to set the background image of the whole webpage. For example,  <body background = “img.jpg”>.

3. What makes HTML a 'Markup' Language?

HTML is a 'Markup' language as it contains standard human-understandable symbols and tags. The basic meaning of markup refers to the marking of data with special information. The tags and characters in HTML specify the text enclosed within them.

4. Which Tag is used to Specifying a Table’s Caption?

The <caption> tag can be used to define the caption of a table.

<caption>TABLE_CAPTION</caption>

5. Define HTML Attributes?

Attributes are used to provide specific information about an element in HTML. To give an attribute to a tag, specify it in the attribute-name= “value” format inside the tag. For example, the “src” attribute for the <image> tag will be specified in the following way:

<image src=“img-name.jpg”>

The common HTML attributes include href, src, alt, id, class, title, and text.

6. Mention all HTML Table Tags?

The following tags are used to create an HTML table.

<table> - This tag is used for defining a table.

<caption> - You can give your table a caption by using this tag.

<tr> - This tag is used to define a row in a table.

<td> - This tag is used to define a cell in a table.

<th> - This tag is used to create a cell in a table.

<tbody> - This tag is used for grouping the body’s content in a table.

<col> - This tag lets you define the column properties of your table.

7. Explain the HTML Layout Structure?

The following tags together build the layout structure of an HTML document.

<header>: The header of the webpage comes under this tag.

<nav>: This tag creates the navigation links of the navbar.

<section>: This defines a section in a web page

<article>: The text written on the web page comes under this tag

<footer>: The footer of the webpage comes under this tag.

<details>: This is used to define additional details

<summary>: This defines a heading for the <details> element

8. How Many Types of Lists are there in HTML?

There are primarily three types of lists in HTML:

  • Ordered List: The ordered lists are used when the elements are needed to be listed in particular orders. For example, numbered-listing, alphabetical-listing, and alpha-numeric-listing. The <ol> tag is used for these lists.
  • Unordered List: Unordered lists are used when the elements don’t need to be listed in a specific order. For example,  bullet-points, square, disc, and circle type listing. The <ul> tag is used for these lists.
  • Description List: The description lists are used to list elements along with associated values. For example, a grocery list with a description of every item.

9. What is the Function of an Anchor Tag?

The anchor tag <a> is used to insert links in the HTML document. It contains an href attribute that creates a hyperlink to files, emails, webpages, and so on. You can also give a name to your tag by adding a name after the href tag. For example:

<a href = “www.google.com”>Google< a/>

10. Differentiate Classes and Id in HTML.

The class and id are the two most widely used general-purpose attributes. They are used to target specific HTML elements and style or manipulate them.

The only difference between the two is that one class=“name” can be shared by any number of elements whereas an id=“value” pair is unique to an HTML element.

11. How do you add Comments in HTML Documents?

The HTML tags are inserted in the comment tag i.e. <!--comment-->. The comments are used to enhance the readability of the HTML code. These comments are not visible on the output web page.

12. Explain the Major Features of HTML5?

HTML5 is superior to its predecessors due to its new features. Some of these features are:

  • HTML5 provides audio and video support.
  • Header and Footer are newly added in HTML5.
  • Nav tag and Progress tag.
  • It also enables you to draw different shapes such as a square, circle, rectangle, etc.

13. How would you Differentiate Inline and Block Elements?

Inline Elements: Those HTML elements that start on the same line as bounded by a tag are known as inline elements. <a>, <strong>, <bold>, <em>, etc are all inline elements.

Block Elements: Elements that start on a different line are called block elements. <div>,
<address>, <footer>, etc., are all block elements.

14. Which tag would you use to create a Scrolling Effect in HTML?

The “Marquee” tag is used to create the scrolling effect on the web page. This effect can be applied to text or images in either horizontal or vertical directions. However, this tag is no longer used by developers due to which it is not present in HTML5.

15. Why is “Doctype” mentioned at the start of an HTML file?

The <!DOCTYPE> declaration is given at the top of an HTML document. This declaration specifies the type of document to the browser.

For example, for an HTML5 document the declaration is- <!DOCTYPE html>. The earlier versions of HTML required a complex doctype declaration.

16. Name some of the New Tags Introduced in HTML5?

There are many new tags introduced in the HTML5 version. These include <figure>, <article>, <audio>, <video>, <canvas>, <embed>, <header>, <footer>, <time>, <section>, <nav>, along with some other useful tags.

There are a total of 32 new tags which were not included in any of the earlier versions of HTML.

17. Highlight the Difference Between HTML and XML?

HTML:  HTML or HyperText Markup Language creates the basic structure of any webpage. It is combined with other tools and technologies like CSS and JS to give additional style and functionality to the webpage.

XML: XML or Extensible Markup language is the ultimate language that defines other markup languages. It defines flexible rules and encoding to define any markup language.

18. List various Formatting Tags in HTML?

The following are the most common formatting tags in HTML.

<b> - To bold the text

<strong> - Highlight the important text

<i> - Italic text

<mark> - Marked text

<small> - To make the text smaller

<del> - Deleted text

<em> - Emphasized text

<ins> - Inserted text

<sub> - Subscript text

<sup> - Superscript text

Bottom Line

This blog showcases some of the frequently asked HTML interview questions that will provide you a deep insight into HTML concepts along with the newly added HTML5 concepts. We sincerely hope that this blog will help you to prepare better for your interviews.

If you are interested to know more about HTML and web development, check out our Full-Stack web development course and become an expert at the front-end and back-end JavaScript technologies of the most popular MERN Stack(MongoDB, Express, React, and Node.js). Learn to build responsive web applications using both front-end and back-end technologies and become an expert Full-Stack Web Developer