Top 50 HTML Interview Questions
Frequently asked in frontend, UI, and full-stack interviews.
1. What is HTML? ⌄
HTML (HyperText Markup Language) is the standard language used to structure content on the web.
2. What are HTML tags? ⌄
Tags are predefined keywords enclosed in angle brackets used to define elements.
3. What is the difference between HTML and HTML5? ⌄
HTML5 introduces semantic elements, multimedia support, APIs, and better performance.
4. What are semantic elements? ⌄
Elements like <header>, <footer>, <article> that describe meaning and structure.
5. What is an attribute? ⌄
Attributes provide additional information about HTML elements.
6. What is the DOCTYPE declaration? ⌄
It tells the browser which HTML version the document uses.
7. What is the difference between block and inline elements? ⌄
Block elements start on a new line; inline elements do not.
8. What are empty elements? ⌄
Elements without closing tags, such as <br> and <img>.
9. What is the <meta> tag? ⌄
Provides metadata like character set, viewport, and SEO information.
10. What is the viewport? ⌄
Defines the visible area of a web page on different devices.
11. What is an anchor tag? ⌄
Used to create hyperlinks using the <a> tag.
12. What is the <img> tag used for? ⌄
Used to embed images in a web page.
13. What is the alt attribute? ⌄
Provides alternative text for images for accessibility and SEO.
14. What is a list in HTML? ⌄
Ordered (<ol>), unordered (<ul>), and description (<dl>) lists.
15. What is a table? ⌄
Used to display data in rows and columns.
16. What is colspan and rowspan? ⌄
They merge table cells horizontally and vertically.
17. What is a form? ⌄
Used to collect user input.
18. What are form elements? ⌄
Input, textarea, select, option, button, label.
19. Difference between GET and POST? ⌄
GET sends data in URL; POST sends data in request body.
20. What is iframe? ⌄
Embeds another HTML document inside the current one.
21. What is canvas? ⌄
Used for drawing graphics using JavaScript.
22. What is SVG? ⌄
Scalable Vector Graphics for resolution-independent images.
23. What is localStorage? ⌄
Stores data in the browser with no expiration.
24. What is sessionStorage? ⌄
Stores data for one browser session.
25. What is cookie? ⌄
Small data stored on the client and sent with HTTP requests.
26. What is accessibility in HTML? ⌄
Designing pages usable by people with disabilities.
27. What is ARIA? ⌄
Accessible Rich Internet Applications attributes.
28. What is SEO-friendly HTML? ⌄
Using semantic tags, meta tags, alt text, and clean structure.
29. What is responsive design? ⌄
Design that adapts to different screen sizes.
30. What is the <picture> tag? ⌄
Provides responsive images based on screen size.
31. What is lazy loading? ⌄
Loads images only when needed to improve performance.
32. What is the <details> tag? ⌄
Creates expandable content blocks.
33. What is the <summary> tag? ⌄
Provides a visible heading for <details>.
34. What is deprecated tag? ⌄
Tags no longer recommended for use.
35. What is the <noscript> tag? ⌄
Displayed when JavaScript is disabled.
36. What is charset? ⌄
Defines character encoding like UTF-8.
37. What is MIME type? ⌄
Defines the type of content sent over HTTP.
38. What is the <link> tag? ⌄
Links external resources like CSS files.
39. What is the <script> tag? ⌄
Used to embed or reference JavaScript code.
40. What is defer attribute? ⌄
Loads script after HTML parsing completes.
41. What is async attribute? ⌄
Loads script asynchronously without blocking rendering.
42. What is HTML validation? ⌄
Checking HTML code against standards.
43. What is W3C? ⌄
World Wide Web Consortium that defines web standards.
44. What is favicon? ⌄
Small icon shown in browser tabs.
45. What is the <base> tag? ⌄
Defines base URL for relative links.
46. What is microdata? ⌄
Provides structured data for search engines.
47. What is Open Graph? ⌄
Metadata used for social media sharing.
48. What is HTML parsing? ⌄
Browser process of converting HTML into DOM.
49. What is web accessibility? ⌄
Ensuring websites are usable by everyone.
50. HTML vs HTML5? ⌄
HTML5 adds semantic tags, APIs, and multimedia support.