Tricky HTML Interview Questions & Answers
1. What is HTML?
HTML (HyperText Markup Language) is the standard markup language used to create web pages.
2. What is the difference between HTML and HTML5?
HTML5 is the latest version with new features like semantic elements, audio/video support, localStorage, and
new input types.
3. What is the structure of an HTML document?
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
Content here
</body>
</html>
4. What are semantic and non-semantic tags?
Semantic tags (like <article>, <header>, <footer>) clearly describe their meaning, while non-semantic tags
(like <div>, <span>) do not.
5. What are different types of input fields in HTML5?
Examples: text, password, email, number, date, color, range, checkbox, radio, submit.
6. What is the purpose of placeholder, required, readonly, and disabled?
- placeholder: shows hint text
- required: makes field mandatory
- readonly: prevents editing
- disabled: disables the field
7. How to validate forms in HTML5?
Use attributes like required, type=email, min, max, pattern, etc., in the <input> tag.
8. How to embed audio and video in HTML?
Page 1
Tricky HTML Interview Questions & Answers
<video controls><source src='movie.mp4' type='video/mp4'></video>
<audio controls><source src='song.mp3' type='audio/mpeg'></audio>
9. How to embed a YouTube video?
<iframe width='560' height='315' src='https://www.youtube.com/embed/xyz'></iframe>
10. What is the difference between internal and external links?
- Internal: link within the same website (e.g., about.html)
- External: link to other websites (e.g., https://google.com)
11. What is the use of target="_blank" in <a> tag?
It opens the link in a new tab or window.
12. What is localStorage and sessionStorage?
- localStorage: Stores data with no expiration.
- sessionStorage: Stores data for one session (until tab is closed).
13. What is the Canvas element?
It allows drawing graphics, charts, and games directly using JavaScript.
14. What is the Geolocation API?
It allows websites to request the user's geographical location (with permission).
15. What is the purpose of the alt attribute in <img>?
It provides alternative text for images, helping screen readers and SEO.
16. What are ARIA roles in HTML?
ARIA roles (Accessible Rich Internet Applications) improve accessibility for screen readers by describing UI
elements.
17. Why is semantic HTML important for SEO?
Semantic tags help search engines understand the page structure and content, improving SEO.
18. What is the viewport meta tag?
<meta name='viewport' content='width=device-width, initial-scale=1.0'>
It ensures the page scales properly on mobile devices.
Page 2
Tricky HTML Interview Questions & Answers
19. How does HTML work with CSS for responsive design?
HTML provides structure while CSS uses media queries and flexible layouts to make pages responsive.
20. What are self-closing tags?
Tags that do not need a closing tag, e.g., <br>, <hr>, <img>, <input>.
21. What are global attributes?
Attributes like id, class, style, title, hidden, tabindex that can be used on any HTML element.
Page 3