HTML Interview Questions and Answers for TCS
1. What is HTML?
HTML (HyperText Markup Language) is the standard markup language used to create and design web
pages. It structures web content using a system of tags.
2. What are HTML tags?
HTML tags are elements enclosed within angle brackets (< >) that define how content should appear on a
web page. Example: <h1>, <p>, <img>.
3. Difference between HTML and HTML5?
HTML:
- No support for audio/video without plugins
- Uses cookies for storage
- Relies on JavaScript for interaction
HTML5:
- Supports <audio> and <video>
- Includes localStorage/sessionStorage
- Built-in APIs like Geolocation, Canvas
4. What are semantic tags in HTML5?
Tags that clearly define their purpose. Examples: <article>, <section>, <nav>, <header>, <footer>.
5. Difference between <div> and <span>?
<div>: Block-level element, used for larger content blocks
HTML Interview Questions and Answers for TCS
<span>: Inline element, used for small inline sections
6. What is the purpose of <!DOCTYPE html>?
It tells the browser which version of HTML is used. For HTML5, we use <!DOCTYPE html>.
7. How is an image inserted in HTML?
<img src="image.jpg" alt="Image description" width="300" height="200">
8. How do you create a hyperlink in HTML?
<a href="https://www.tcs.com">Visit TCS</a>
9. Difference between id and class attributes?
id: Unique, used once per page, referenced with # in CSS
class: Can be reused, referenced with . in CSS
10. What are empty elements in HTML?
Elements without closing tags: <br>, <hr>, <img>
11. How can you make a form in HTML?
<form action="/submit" method="post">
<input type="text" name="name">
<input type="submit">
</form>
HTML Interview Questions and Answers for TCS
12. Difference between GET and POST methods?
GET: Appends data to URL, less secure, limited length
POST: Sends data in request body, more secure
13. What are meta tags?
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
14. What is the <canvas> element?
Used to draw graphics using JavaScript (charts, games, etc.).
15. How does HTML handle whitespace?
HTML collapses whitespace. Use <pre> or CSS (white-space: pre;) to preserve formatting.