HTML Interview Questions & Answers

Top questions asked in interviews for freshers & experienced developers

1. What is HTML?
HTML stands for HyperText Markup Language. It is used to structure web pages.
2. What are HTML tags?
HTML tags are keywords enclosed in angle brackets used to define elements.
3. Difference between HTML and HTML5?
HTML5 includes semantic tags, multimedia support, APIs, and better performance.
4. What are semantic elements?
Semantic elements clearly describe their meaning, like <article>, <section>, <header>.
5. What is the use of <meta> tag?
It provides metadata like description, keywords, charset, and viewport.
6. Difference between inline and block elements?
Block elements start on a new line, inline elements do not.
7. What is an attribute?
Attributes provide additional information about HTML elements.
8. What is DOCTYPE?
DOCTYPE tells the browser which version of HTML is used.
9. What is the use of iframe?
iframe is used to embed another document inside the current page.
10. What is localStorage?
localStorage stores data in the browser with no expiration time.
11. What is sessionStorage?
sessionStorage stores data temporarily for one browser session.
12. What is the <head> tag?
It contains metadata, title, styles, and scripts of the document.
13. What is the <body> tag?
It contains the visible content of a web page.
14. What is an empty element?
An element without closing tag, like <br> or <img>.
15. What is the <img> tag used for?
It is used to embed images in a web page.
16. What is the <a> tag?
It is used to create hyperlinks.
17. What is an absolute URL?
A full URL including protocol, domain, and path.
18. What is a relative URL?
A URL relative to the current page location.
19. What is the <table> tag?
It is used to display data in rows and columns.
20. What are <tr>, <td>, <th>?
They define table row, table data, and table header.
21. What is the <form> tag?
It is used to collect user input.
22. What is the <input> tag?
It creates input fields like text, email, password, etc.
23. What is placeholder attribute?
It shows a hint inside an input field.
24. What is required attribute?
It makes an input field mandatory.
25. What is the <label> tag?
It defines labels for form elements.
26. What is the <select> tag?
It creates a dropdown list.
27. What is the <textarea> tag?
It creates a multi-line text input.
28. What is the <button> tag?
It creates a clickable button.
29. What is the <div> tag?
It is a block-level container element.
30. What is the <span> tag?
It is an inline container element.
31. What is the <section> tag?
It groups related content into sections.
32. What is the <article> tag?
It represents independent, self-contained content.
33. What is the <nav> tag?
It defines navigation links.
34. What is the <footer> tag?
It defines footer content of a page or section.
35. What is the <header> tag?
It defines header content.
36. What is the <aside> tag?
It defines content aside from main content.
37. What is the <audio> tag?
It is used to embed audio content.
38. What is the <video> tag?
It is used to embed video content.
39. What is the <canvas> tag?
It is used to draw graphics using JavaScript.
40. What is the <svg> tag?
It is used to display vector graphics.
41. What is the <br> tag?
It inserts a line break.
42. What is the <hr> tag?
It creates a horizontal rule.
43. What is the <strong> tag?
It defines important text.
44. What is the <em> tag?
It emphasizes text.
45. What is the <code> tag?
It displays code snippets.
46. What is the <pre> tag?
It preserves formatting and whitespace.
47. What is the <time> tag?
It represents date or time.
48. What is the <details> tag?
It creates expandable content.
49. What is the <summary> tag?
It defines a summary for details element.
50. What is the <progress> tag?
It shows progress of a task.
51. What is the <meter> tag?
It measures a scalar value.
52. What is lazy loading?
It delays loading images until needed.
53. What is the loading attribute?
It enables lazy loading for images.
54. What is favicon?
It is the small icon shown in browser tabs.
55. What is accessibility in HTML?
It ensures web content is usable by everyone.
56. What is alt attribute?
It provides alternative text for images.
57. What is the role of ARIA?
ARIA improves accessibility for screen readers.
58. What is HTML validation?
It checks HTML code for errors.
59. What is W3C?
World Wide Web Consortium defines web standards.
60. Why is HTML important?
HTML is the foundation of all web pages.
⚠️ Right-click is disabled on this page!