HomeBytesheetsRoadmapsUI TemplatesUI ToolsStack Discussion
60 Topics
Chapter•120 Minutes

HTML Questions

Test your HTML knowledge with 60 interview-style questions covering fundamentals, semantics, forms, accessibility, SEO, performance, and advanced HTML.

1. What is HTML?

HTML stands for HyperText Markup Language. It is the standard markup language used to structure content and describe its semantics on the web. HTML defines elements such as headings, paragraphs, links, forms, images, tables, and semantic page regions.

Key Takeaways
  • HTML is a markup language.
  • HTML defines structure and semantics rather than application logic.
Knowledge Check

What is HTML primarily used for?

2. Is HTML a programming language?

No. HTML is a markup language. It describes document structure and semantics but does not provide the general-purpose programming constructs associated with programming languages, such as functions, loops, and algorithmic control flow.

Key Takeaways
  • HTML is declarative markup.
  • JavaScript is commonly used when programming behavior is required.
Knowledge Check

Why is HTML not generally classified as a programming language?

3. What is HTML5?

HTML5 refers to the modern evolution of HTML and the collection of web platform capabilities standardized around HTML. It introduced or standardized many semantic elements and native capabilities such as audio, video, canvas, forms improvements, and more.

Key Takeaways
  • Modern HTML includes semantic and multimedia capabilities.
  • HTML continues to evolve as a web standard.
Knowledge Check

Which is associated with modern HTML capabilities?

4. What is the purpose of <!DOCTYPE html>?

It tells the browser to use standards mode for the document. The modern HTML doctype is intentionally simple: <!doctype html>.

Key Takeaways
  • DOCTYPE is a declaration.
  • Use the modern HTML doctype in HTML documents.
Knowledge Check

What does <!doctype html> primarily do?

5. What is the difference between an element and a tag?

A tag is the markup syntax such as <p> or </p>. An element is the complete construct, including its opening tag, content, and closing tag when applicable. For example, <p>Hello</p> is a paragraph element.

Key Takeaways
  • Tags are syntax.
  • Elements represent document nodes and their semantics.
Knowledge Check

Which represents the complete HTML element?

6. What are void elements?

Void elements are HTML elements that cannot have child content and do not use closing tags. Examples include <img>, <input>, <br>, <hr>, <meta>, and <link>.

Key Takeaways
  • Void elements do not contain child nodes.
  • Do not add unnecessary closing tags to void elements.
Knowledge Check

Which is a void element?

7. What is the DOM?

The Document Object Model is an object representation of a document that scripts and browser APIs can interact with. The browser parses HTML and creates a tree of nodes representing the document.

Key Takeaways
  • The DOM represents document structure.
  • JavaScript commonly interacts with the DOM.
Knowledge Check

What does the DOM represent?

8. What is semantic HTML?

Semantic HTML uses elements that communicate the meaning or role of content. Examples include <article>, <nav>, <main>, <header>, and <footer>. Semantic markup improves structure, accessibility, maintainability, and machine understanding.

Key Takeaways
  • Semantics communicate meaning.
  • Prefer meaningful HTML over generic containers when appropriate.
Knowledge Check

Which is a semantic HTML element?

9. What is the difference between div and span?

Both are generic containers. <div> is normally used as a block-level structural container, while <span> is an inline phrasing container. Neither adds meaningful semantics by itself.

Key Takeaways
  • div and span are generic.
  • Use semantic elements when one accurately describes the content.
Knowledge Check

Which statement is correct?

10. What is the purpose of the lang attribute?

The lang attribute identifies the language of the element's content. Setting it on the root <html> element helps browsers, search engines, translation tools, and assistive technologies interpret the document correctly.

Key Takeaways
  • Declare the document's language.
  • Language metadata supports accessibility and user agents.
Knowledge Check

Where is the primary document language commonly declared?