HTML Interview Questions

By | July 8, 2019

If you have a keen interest in front-end development and also have some experience, and preparing for a Job interview here in this article we have provided top HTML interviews question often asked in interviews.

HTML Interview Questions

Question: What is HTML?

Answer: HTML is an acronym of HyperText Markup Language, it is a markup language used by WWW (World Wide Web) to create web pages. 

Question: What is HTML 5?

Answer: HTML 5 is the latest edition of HTML and the latest language used by WWW. 

Question: Can I hide my HTML code from the user?

Answer: No, the browser needs our code to display the web-pages and the browser allows the users to see the code.

Question: Give some new features introduced in HTML5.


  • It has introduced new elements and attributes.
  • New semantic elements like <header> and <footer>
  • It comes with bi-directional communication for web applications
  • It introduced Server-Sent Events (SSE)
  • It allows us to add audio and video in the web pages.

Question: Give some difference between HTML and HTML5.


It has a large document Its document is less than HTML
There were no <audio> and <video> tags in HTML In HTML5 we got new features like <audio> and <video>
HTML is supported on every browser, even on old once. We need updated browsers to run HTML5
There were no web sockets in HTML In HTML5 we got full duplex communication channel
In HTML we have not any vector technology HTML5 comes with an integral vector technology

Question: Why do we write Doctype at the top of each HTML page?

Answer: Doctype is a special syntax given to HTML pages, it is a syntax because <!DOCTYPE> is not a tag. The Doctype statement in HTML tells the browser to open this web page in a standard mode and it acquaints the web page with the latest edition of HTML without specifying the specific versions.

Question: What happens if we do not mention <!DOCTYPE> in an HTML page?

Answer: We would not be able to avail the latest features of HTML and get stuck with the old ones. If there is no <!DOCTYPE>, the browser will get no information about the version of the HTML used in that specific web page.

Question: What are tags?

Answer: Tags are kind of pre-defined code in HTML they start with < sign and end with > sign, it tells browser what to do. Once we have opened a tag, we have to close it and to close a tag we use / symbol. Most of the HTML tag come in pairs. E.g. <h1> </h1>, <p> </p>, etc.

Question: Do all HTML tags come in pair?

Answer: No, some tags like <img>, <br> etc. does not have any pair.

Question: Name all the list we use in HTML.


  • Ordered list
  • Unordered list
  • Definition list
  • Menu list
  • Directory list

Question: Name new media elements in HTML5.


  • <audio>
  • <video>
  • <source>
  • <embed>
  • <track>

Question: Why we use canvas element in HTML5?

Answer: HTML5 has a new element known as a canvas which is used to create charts, graphs, photoshop 2-D images and lots more.

Question: What are comments in HTML and how to insert one?

Answer: Comments are the special statements in HTML which do not execute and not display on the web browser. We write comment inside <!  > tag, for example: <!—Comment —>

Question: What is the key difference between HTML elements and tags?

Answer: Elements are the predefined code that renders the text in different formats, and when an element enclosed by brackets <> they make tags.

Question: Name all the heading HTML consist.

Answer: HTML has 6 headings from <h1> to <h6> and each heading has its own size, the size descended from <h1> to <h6>.

<h1>Heading 1</h1>
<h2>Heading 2</h2>
<h3>Heading 3</h3>
<h4>Heading 4</h4>
<h5>Heading 5</h5>
<h6>Heading 6</h6>

Question: How can we format the HTML text?

Answer: HTML provides us tags like <strong>, <em> <i> to format the text, so it could become more legible and provide a rich interface.

Question: Mention some new Form elements introduced in HTML5.

Answer: Web pages use forms to collect data from the user to the appropriate operations can be performed at the back end. Though before HTML5, HTML use different kinds of forms elements like text field, password, drop-down menus, etc.

In HTML5 some new elements are introduced such as <datalist>, <keygen> and <output>

Question: Name the types of Web storage in HTML5.

Answer: HTML5 has two types of Web storage:

  • Session storage: In session storage data store temporarily until the browser is closed. Once we closed the browser the data get lost
  • Local Storage: In local storage data does not get deleted even the browser is closed, to delete the data we have to manually visit the browser setting.

Question: Give two advantages of HTML5 web storage.


  • It has a storage of 10 MB which is more than what cookie could have
  • The storage data can be transferred through HTTP requests.

Question: Give a key difference between Semantic and Non-Semantic Elements:


  • Semantic elements give a clear meaning to their content and only work on a specific flow. For example, <img> element as by its name itself this element is used to insert images in web pages and it gives a proper meaning.
  • Non-Semantic elements in HTML does not give a proper meaning. For example, <spam> and <div>.

Question: Can we get the Geographical Position of a user using HTML?

Answer: Yes, HTML 5 provides us with a feature Geolocation API which can retrieve the location of a user.

Question: Can we apply a hyperlink on images?

Answer: Yes, a hyperlink can be applied to images.

Question: Mention the Hierarchy of applying Style sheet in an HTML page.


  • The inline sheet comes first.
  • Embedded sheet.
  • External Sheet.

Question: Can we show all characters using HTML?

Answer: No, it depends on the Operating system on which that browser is running.

Question: What is an image map?

Answer: In a single image, we can create different clickable areas and each area can refer to different web page this method of mapping different webpages on a single image known as an image map.

Question: Is HTML a programming language?

Answer: No, it is not a programming language, though its code gets interpreted by our browser, code execution is not enough to be a programming language.

Question: How does the browser interpret the white space?

Answer: The browser does not consider white space when it is between two different tags, but it becomes a character when it used inside a tag.

Question: How can we create such links that scroll to the same page?

Answer: To scroll in the same page we use # symbol along with the <a> tag. First, we assign a link using <a> tag and href attribute then again create a <a> tag having the same name.

For example:

<a href = ”#gothere” >  Go There </a>
<a name =”gothere”>

Question: Why do we use alternative text in image mapping?

Answer: In image mapping, the user can get easily confused with, which are links to which webpage so we provide an alternate text to each area so the user can figure out which area links to which page.

Question: Can we run old HTML files on a new browser?

Answer: Yes, but it could be possible some of the text won’t get executed, because of the new features.

Question: What happens if the user operating system does not support some HTML characters?

Answer: The user won’t be able to read the character because the operating system will show some random square or circle like characters.

Question: Which two attributes a <li> tag consist?

Answer: <li> tag has two attributes type and value. The type attribute used to change the type of numbering and the value attribute is used to change the number of indexing.

Question: What are bullets in HTML?

Answer: Bullets in HTML represented with Unordered list. We can set the attribute of the unordered list to a disc, square or circle.

Question: What is an empty HTML element?

Answer: An HTML element with no content or test associated with it is known as empty HTML element for example <br>

Question: What are nested tables and how to create those?

Answer: When we create a table inside a table, we call it a nested table.

For example:

<td> ‘’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’</td>
<td>’’’’’’’’’’’ </td>
<td> ‘’’’’’’’’’’’’’’’’’’’’’</td>

Question: How can we create multicolor text on a web page?

Answer: To create a multicolor text we have to change the color of each text for that we have to individually visit every text and change its color using <font color =” color”> text </font>.

Question: In HTML why do we have numeric as well as character values for different attributes?

Answer: In HTML we can use both ASCII values as well as name values for an attribute. Though ASCII values are sufficient for the attribute we require name values too because they are easy to remember.

Question: How can we insert a copyright symbol using ASCII number?

Answer: &#169

Question: Can we change the color of the bullets?

Answer: Yes, but indirectly the color of the bullet depends upon the color of the list text, so in order to change the color of bullet we need to change the color of list text.

Question: What is a marquee?

Answer: In HTML, we use the <marquee> tag to display running text or image.

Question: How can we link a .css file in our HTML code?

Answer: To link a .css file in our HTML we use  <link> tag and href attribute, the the link tag should be inside <head> tag.

<link href="/css/style.css" type="text/css" rel="stylesheet" />

Question: What is Non-Breaking Space in HTML?

Answer: While writing any text in content if we add more than one space at once, the HTML remove all the extra spaces and keep only one of those, this removal of spaces problem can be solved with Non-Breaking Space (&NBSP;), to add more than one space we use &nbsp;

Question: What is the key difference between cell padding and cell spacing?


  • Cell Padding refers to the gap between the text content and the cell border or wall
  • Cell Spacing is a gap between two cells of the same table.

Question: What is CSS?

Answer: CSS stands for Cascading Style Sheet and it is used by HTML to style its black and white text. CSS provides an interactive interface to the HTML and play a vital role while creating a web page.

Question: What happens if two tag overlap?

Answer: If two tags get overlap the tag which is written first will come under the HTML consideration and the content of the second tag adjust according to the first tag. This could cause many problems and you will not get satisfactory results.

Question: What is Applet?

Answer: The applet is a Java program that can be embedded into a web page, it includes some functionality on the webpage and provides a dynamic approach to the webpages. The Applet executes at the client side and which mean it can be easily run on the browser.

Question: What happens if there is no text in between a tag?

Answer: If there is no text only tag, so there is nothing to format and we would get nothing on the screen when we execute the HTML file on browser.

Question: Can we link a single <a> with two different web pages?

Answer: No, when we create <a> tag it accepts only one href attribute.

Question: Comment on text field size.

Answer: The default size of a text field is 13 characters but it has an attribute name size which can alter the character size from 1 character to many characters. The maximum size of a character depends upon the browser width.

Question: What is the case when the text shows out of the browser?

Answer: When a text is inside a table with a fixed width, in this case, the text content of the table can be extended beyond the browser window.

Question: Write an HTML code that uses a picture as a background.

Answer: <body background = “image.gif”>

One thought on “HTML Interview Questions

  1. Ashwarya Ralhan

    Can You Please tell me that what are the best sites through I can get some HTML5 Certification?


Leave a Reply

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