Skip to content

HTML Interview Questions

HTML Interview Questions and Answers

  1. Are the HTML tags and elements the same thing?
  2. What are tags and attributes in HTML?
  3. What are void elements in HTML?
  4. What is the advantage of collapsing white space?
  5. What are HTML Entities?
  6. What are different types of lists in HTML?
  7. What is the class attribute in HTML?
  8. What is the difference between the id attribute and the class attribute of HTML elements?
  9. Define multipart form data?
  10. Describe HTML layout structure.
  11. How to optimize website assets loading?
  12. What are the various formatting tags in HTML?
  13. What are the different kinds of Doctypes available?
  14. Please explain how to indicate the character set being used by a document in HTML?
  15. What is the difference between <b> tags and <strong> tags?
  16. What is the significance of <i> and <em> tag in HTML?
  17. Can we display a web page inside a web page or is nesting of webpages possible?
  18. How is Cell Padding different from Cell Spacing?
  19. How can we club two or more rows or columns into a single row or column in an HTML table?
  20. Is it possible to change an inline element into a block level element?

HTML Interview Questions (Continued)

  1. In how many ways can we position an HTML element? Or what are the permissible values of the position attribute?
  2. In how many ways can you display HTML elements?
  3. What is the difference between display: none and visibility: hidden when used as attributes to the HTML element?
  4. How to specify the link in HTML and explain the target attribute?
  5. In how many ways can we specify the CSS styles for the HTML element?
  6. Difference between <link> tag and <a> (anchor) tag?
  7. How to include JavaScript code in HTML?
  8. When to use scripts in the <head> and when to use scripts in the <body>?
  9. What are forms and how to create forms in HTML?
  10. How to handle events in HTML?

HTML5 Interview Questions

  1. What are some of the advantages of HTML5 over its previous versions?

  2. How can we include audio or video in a webpage?

  3. Inline and block elements in HTML5?

  4. Are the HTML tags and elements the same thing?

    • No, HTML tags are the markup used to create HTML elements. An element consists of a start tag, content, and an end tag.
  5. What are tags and attributes in HTML?

    • Tags are the building blocks of HTML that define elements, while attributes provide additional information about those elements.
  6. What are void elements in HTML?

    • Void elements are HTML elements that do not have closing tags and cannot contain any content, such as <img>, <br>, and <hr>.
  7. What is the advantage of collapsing white space?

    • Collapsing white space helps to improve readability and maintain a clean layout by reducing unnecessary spaces in the HTML code.
  8. What are HTML Entities?

    • HTML Entities are special codes used to represent characters that have special meanings in HTML, such as &amp; for & and &lt; for <.
  9. What are different types of lists in HTML?

    • HTML supports three types of lists: ordered lists (<ol>), unordered lists (<ul>), and definition lists (<dl>).
  10. What is the class attribute in HTML?

    • The class attribute is used to assign one or more class names to an HTML element, allowing for CSS styling and JavaScript manipulation.
  11. What is the difference between the id attribute and the class attribute of HTML elements?

    • The id attribute is unique to a single element, while the class attribute can be shared among multiple elements.
  12. Define multipart form data?

    • Multipart form data is a way to encode form data that allows files to be uploaded along with other form fields.
  13. Describe HTML layout structure.

    • HTML layout structure typically consists of a header, navigation, main content area, sidebar, and footer.
  14. How to optimize website assets loading?

    • Optimize website assets loading by minimizing file sizes, using caching, lazy loading images, and combining files.
  15. What are the various formatting tags in HTML?

    • Formatting tags in HTML include <b>, <i>, <u>, <strong>, <em>, <mark>, and <small>.
  16. What are the different kinds of Doctypes available?

    • Common Doctypes include HTML5 (<!DOCTYPE html>), HTML 4.01 Strict, HTML 4.01 Transitional, and XHTML 1.0.
  17. Please explain how to indicate the character set being used by a document in HTML?

    • The character set can be indicated using the <meta charset="UTF-8"> tag within the <head> section of the HTML document.
  18. What is the difference between <b> tags and <strong> tags?

    • The <b> tag is used for stylistic bolding, while the <strong> tag indicates that the text is of strong importance.
  19. What is the significance of <i> and <em> tag in HTML?

    • The <i> tag is used for italicizing text for stylistic purposes, while the <em> tag indicates emphasis on the text.
  20. Can we display a web page inside a web page or is nesting of webpages possible?

    • Yes, we can display a web page inside another web page using the <iframe> tag.
  21. How is Cell Padding different from Cell Spacing?

    • Cell Padding is the space between the cell content and its border, while Cell Spacing is the space between adjacent cells in a table.
  22. How can we club two or more rows or columns into a single row or column in an HTML table?

    • We can use the rowspan attribute to merge rows and the colspan attribute to merge columns in an HTML table.
  23. Is it possible to change an inline element into a block level element?

    • Yes, we can change an inline element into a block-level element using CSS by setting the display property to block.

HTML Interview Questions (Continued)

  1. In how many ways can we position an HTML element? Or what are the permissible values of the position attribute?
    • HTML elements can be positioned using static, relative, absolute, fixed, and sticky values for the position property in CSS.
  2. In how many ways can you display HTML elements?
    • HTML elements can be displayed using block, inline, inline-block, flex, grid, and none values for the display property in CSS.
  3. What is the difference between display: none and visibility: hidden when used as attributes to the HTML element?
    • display: none removes the element from the document flow, while visibility: hidden hides the element but still occupies space in the layout.
  4. How to specify the link in HTML and explain the target attribute?
    • Links are specified using the <a> tag with the href attribute. The target attribute specifies where to open the linked document (e.g., _blank for a new tab).
  5. In how many ways can we specify the CSS styles for the HTML element?
    • CSS styles can be specified using inline styles, internal stylesheets, and external stylesheets.
  6. Difference between <link> tag and <a> (anchor) tag?
    • The <link> tag is used to link external resources like stylesheets, while the <a> tag is used to create hyperlinks to other pages or resources.
  7. How to include JavaScript code in HTML?
    • JavaScript code can be included using the <script> tag, either inline or by linking to an external JavaScript file.
  8. When to use scripts in the <head> and when to use scripts in the <body>?
    • Scripts in the <head> are loaded before the page content, while scripts in the <body> are loaded after the content, which can improve page load times.
  9. What are forms and how to create forms in HTML?
    • Forms are used to collect user input and can be created using the <form> tag along with various input elements like <input>, <textarea>, and <button>.
  10. How to handle events in HTML?
    • Events can be handled using event attributes (e.g., onclick, onchange) in HTML elements or by using JavaScript event listeners.

HTML5 Interview Questions

  1. What are some of the advantages of HTML5 over its previous versions?
    • HTML5 offers improved multimedia support, new semantic elements, better form controls, offline capabilities, and enhanced performance.
  2. How can we include audio or video in a webpage?
    • Audio and video can be included using the <audio> and <video> tags, respectively, with various attributes for controls and sources.
  3. Inline and block elements in HTML5?
    • Inline elements do not start on a new line and only take up as much width as necessary (e.g., <span>, <a>), while block elements start on a new line and take up the full width available (e.g., <div>, <p>).