Home » HTML Interview Questions and Answers

HTML Interview Questions and Answers

In this article we have gathered the latest and most asked HTML Interview Questions and Answers for both freshers and experienced candidates. This list also covers some HTML CSS interview questions to help you start or move ahead in your career in web development or HTML. Here we have gathered both the basic as well as advanced HTML Interview questions for freshers and experienced level candidates.

HTML stands for Hyper Text Markup Language. HTML is the standard markup language used to display designed documents in web browsers. Without this language, it is nearly impossible to organize text, add video or images to a web page. It is the standard text formatting language used to create and display pages on the web. HTML documents are made up of two things: the content and the tags that format it for proper display on pages.

HTML Interview Questions and Answers

Here are the top commonly asked HTML interview questions and answers for both freshers and experienced candidates. These HTML Interview Questions will help job seekers to prepare well for the job interview and cross the panel discussion easily.

So let’s get started :

1. What is HTML?
2. What are tags?
3. Do all HTML tags have an end tag?
4. What is formatting in HTML?
5. Write the basic structure of the HTML template.
6. What are the common lists that can be used when designing a page?
7. How to create a hyperlink in HTML?
8. What are HTML Attributes?
9. What is semantic HTML?
10. How to insert a copyright symbol on a browser page?
11. What is a style sheet?
12. Is it possible to change the color of the bullet?
13. What is a marquee?
14. Explain the use of an iframe tag.
15. Explain the layout of HTML?
16. What are empty elements?
17. Does a <!DOCTYPE html> tag is a HTML tag?
18. What is the difference between LocalStorage and SessionStorage Objects?
19. What is the use of the figure tag in HTML5?
20. What is the difference between display: none and visibility: hidden?
21. Will HTML5 work if I don’t use <!DOCTYPE html>?
22. What is the difference between <div> and <span> tag?
23. What is the use of Geolocation API in HTML5?
24. Is it possible for the text to occasionally appear elsewhere other than the browser?
25. What happens if you open the external CSS file in a browser?

1. What is HTML?

HTML or Hypertext Markup Language was created in 1991 by Berners-Lee. It is a markup language used to create and structure website templates or web pages for presenting content on the World Wide Web. It consists of a series of elements and HTML elements tell the browser how to display the content. HTML helps in making the text more interactive and dynamic. You can save an HTML page by appending .html or .html to the name of the web page.

You May Also Like :   CSS Interview Questions and Answers

2. What are tags?

HTML tags are made up of three things: an opening tag, content, and ending tag. Some tags are unclosed tags. The content is placed between HTML tags for proper formatting. It uses the less-than symbol (<) and the greater-than symbol (>). The slash symbol (/) is also used as a closing tag. For Example:

<tag> content </tag>

3. Do all HTML tags have an end tag?

No. There are some HTML tags that don’t need a closing tag. For example: <image> tag, <br> tag.


4. What is formatting in HTML?

HTML formatting is the process of formatting text for better look and feel. It uses different tags to make the text bold, italic, underline.


5. Write the basic structure of the HTML template.

The basic structure of the HTML template is:

<html>

      <head>

                <title>Title of the page</title>

      </head>

      <body>content of the page</body>

</html>

6. What are the common lists that can be used when designing a page?

The following are the most commonly used lists that are used when designing a page:

  • unordered list (<ul> tag) – displays elements in a bulleted format.
  • ordered list (<ol> tag) – displays elements in a numbered format.
  • definition list (<dl>, <dt> and <dd> tags) – displays elements in definition form like in a dictionary.

HTML provides an anchor tag to create a hyperlink that links one page to another. These tags can appear in any of the following ways:

  • Unvisited link – It is displayed, underlined and blue.
  • Visited link – It is displayed, underlined and purple.
  • Active link – It is displayed, underlined and red.

8. What are HTML Attributes?

HTML attributes provide additional information about HTML elements. They are defined directly after the tag name. They appear only in opening tags and not in closing tags. HTML attributes usually consist of name/value pairs such as name=”value”. Attribute values must always be enclosed in quotation marks. The name parameter takes the name of the property to be assigned to the element. The value takes a range of property values or property names that can be aligned on the element.


9. What is semantic HTML?

Semantic HTML is a coding style. It is the use of HTML markup to reinforce the meaning or meaning of the content in webpages and web applications and not just to define its look or feel. It introduces the meaning of the code we write. For example:

<form>, <table>, and <article> these tags clearly defines its content.

You May Also Like :   AWS Interview Questions and Answers

You can insert a copyright symbol by using &copy; or &#169; in an HTML file.


11. What is a style sheet?

A style sheet is used to construct a consistent, transportable, and well-designed style template. You can add these templates to many different web pages. It describes the look and formatting of a document written in a markup language.


12. Is it possible to change the color of the bullet?

The color of the bullet is always the color of the first text in the list. So, if you want to change the color of the bullet, you have to change the color of the text.


13. What is a marquee?

The marquee tag is a non-standard HTML element that causes text to automatically scroll up, down, left, or right. You can put the text you want to scroll on the web page within the following tags:

<marquee>……</marquee>

14. Explain the use of an iframe tag.

The tag specifies an inline frame. It is used to display a web page within a web page (for embedding another document within the current HTML document).</p>

For example – SRC attribute is used to specify the URL of the document which is in the iframe.

<iframe src=”URL”></iframe>

15. Explain the layout of HTML?

HTML layout specifies the way in which a web page is organized. Following are the various HTML5 elements that are used to define different parts of a webpage.

  • <header> : It is used to define a header for a document or a section.
  • <nav> : It is used to define a container for navigation links
  • <section> : It is used to define a section in a document
  • <article> : It is used to define an independent, self-contained article
  • <aside> : It is used to define content aside from the content (like a sidebar)
  • <footer> : It is used to define a footer for a document or a section

16. What are empty elements?

HTML elements with no content are called empty elements. For example: <br>, <hr> etc.


17. Does a <!DOCTYPE html> tag is a HTML tag?

No, the declaration is not an HTML tag. There are many types of HTML eg. HTML 4.01 Strict, HTML 4.01 Transitional, HTML 4.01 Frameset, XHTML 1.0 Strict, XHTML 1.0 Transitional, XHTML 1.0 Frameset, XHTML 1.1 etc. Therefore, is used to instruct the web browser about the HTML page.


18. What is the difference between LocalStorage and SessionStorage Objects?

The differences between LocalStorage and SessionStorage Objects are:

LocalStorage ObjectSessionStorage Object
It stores the data without an expiry date.Stores the data for only one session.
Data is not deleted when the browser window closes.The data is deleted if the browser window closes.
The data can be shared between multiple windows of the browser.Data is accessible only in the current window of the browser.

19. What is the use of the figure tag in HTML5?

The <figure> tag identifies self-contained content related to the main content. It is used to add self-contained content such as photos, diagrams, illustrations, etc. The figure, its title, and its contents are referred to as a single entity from the main flow of the document. The <figure> tag contains two elements img src and figcaption. Img src is used to add the image source to the document while figcaption sets the title of the image.

You May Also Like :   OS Interview Questions and Answers

20. What is the difference between display: none and visibility: hidden?

When an HTML element has the “visibility: hidden” property, it will be hidden from the web page, yet still take up space. However, if we apply the “display: none” property to the HTML element, the element will remain hidden and take up no space on the website.


21. Will HTML5 work if I don’t use <!DOCTYPE html>?

No, HTML 5 tags will not work properly and the browser will not be able to tell that this is an HTML document.


22. What is the difference between <div> and <span> tag?

The difference between span and div elements is that the span element is in-line and is typically used for a short paragraph or other small block of HTML within a line. A div or division element, on the other hand, is a block line, which is equivalent to having a line break before and after it and is used to combine larger chunks of code.


23. What is the use of Geolocation API in HTML5?

One of the best HTML5 API is the Geolocation API which is used for web applications to determine the user’s geographic location. With HTML5, you can now browse the latitude and longitude coordinates of a visitor’s current website. These coordinates can be recorded by JavaScript and sent to the server, allowing it to display your position on the page. The Geolocation API is used with the navigation.geolocation object. A Geolocation object that contains the user’s location information and can generate a customized result is returned through the read-only property of the object.


24. Is it possible for the text to occasionally appear elsewhere other than the browser?

By default, text automatically wraps to fit the browser window. However, the text may go outside the browser window if it is a component of a table cell with a fixed width.


25. What happens if you open the external CSS file in a browser?

When you try to open an external CSS file in a browser, the browser can’t open the file because the file has a different extension. The only way to use an external CSS file is to reference it in another HTML document using the <link/> tag.


We hope that the frequently asked HTML Interview Questions and Answers in this post will help you to crack your next interview and bag your dream job.

All The Best!

4.5/5 - (2 votes)
Scroll to Top