Top Interview HTML Questions For TCS
Top Basic HTML Interview Questions and Answers for TCS
Introduction
Are you preparing for an HTML interview at TCS? HTML (HyperText Markup Language) is the foundation of web development, used to structure web pages with elements like headings, paragraphs, forms, tables, and multimedia content. TCS evaluates candidates based on their understanding of HTML tags, attributes, semantic elements, forms, accessibility, and best practices.
This blog provides a comprehensive list of frequently asked HTML interview questions at TCS, covering essential topics for both freshers and experienced professionals.
✔ Covers fundamental to advanced HTML topics
✔ Includes practical coding examples
✔ Useful for technical interviews at TCS
📌 Bookmark this page to revise the most important HTML interview questions before your TCS interview! 🚀
Top Basic HTML Interview Questions and Answers
1. What is HTML?
Answer: HTML (HyperText Markup Language) is the standard language for creating web pages. It defines the structure of a webpage using elements like headings, paragraphs, links, images, and lists.
2. What are the different types of HTML elements?
Answer:
- Block-level elements – Occupy the full width of their container (e.g.,
<div>
,<p>
,<h1>
). - Inline elements – Only take up as much space as necessary (e.g.,
<span>
,<a>
,<b>
). - Self-closing elements – Do not require a closing tag (e.g.,
<img>
,<input>
,<br>
).
3. What is the difference between HTML and HTML5?
Answer:
Feature | HTML | HTML5 |
---|---|---|
Multimedia Support | Limited | Supports <audio> and <video> |
Semantic Elements | Not well-defined | Introduces <article> , <section> , <nav> |
Form Elements | Basic | New input types like email , date , range |
Graphics | Uses external plugins | Supports <canvas> and <svg> |
4. What are semantic elements in HTML?
Answer: Semantic elements clearly define their meaning in a webpage. Examples include:
<header>
– Represents the top section of a webpage.<nav>
– Defines navigation links.<section>
– Groups related content.<article>
– Represents independent content.<footer>
– Defines the bottom section of a webpage.
5. What is the difference between id
and class
attributes in HTML?
Answer:
Feature | id | class |
---|---|---|
Uniqueness | Unique for each element | Can be used on multiple elements |
Usage | Identifies a single element | Groups similar elements |
Example | <div id="header"> | <div class="content"> |
6. What is the difference between <div>
and <span>
?
Answer:
Element | Description |
---|---|
<div> | A block-level container used for layout and styling |
<span> | An inline element used to style small portions of text |
Example:
<div style="background: lightgray;">Block Element</div>
<span style="color: red;">Inline Element</span>
7. What are the different types of lists in HTML?
Answer:
- Ordered List (
<ol>
) – Displays items in a numbered format.<ol> <li>Item 1</li> <li>Item 2</li> </ol>
- Unordered List (
<ul>
) – Displays items with bullet points.<ul> <li>Item A</li> <li>Item B</li> </ul>
- Definition List (
<dl>
) – Represents a list of terms and definitions.<dl> <dt>HTML</dt> <dd>HyperText Markup Language</dd> </dl>
8. What is the difference between <thead>
, <tbody>
, and <tfoot>
in an HTML table?
Answer:
Tag | Description |
---|---|
<thead> | Groups the header content of a table |
<tbody> | Contains the main content of the table |
<tfoot> | Represents the footer section of a table |
Example:
<table>
<thead>
<tr><th>Name</th><th>Age</th></tr>
</thead>
<tbody>
<tr><td>Alice</td><td>25</td></tr>
</tbody>
<tfoot>
<tr><td colspan="2">Footer</td></tr>
</tfoot>
</table>
9. What is the purpose of the <meta>
tag in HTML?
Answer: The <meta>
tag provides metadata about a webpage.
Example:
<meta name="description" content="HTML interview questions for TCS">
<meta name="keywords" content="HTML, interview, TCS">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
10. What is an HTML iframe?
Answer: An <iframe>
is used to embed another webpage within a webpage.
Example:
<iframe src="https://www.example.com" width="600" height="400"></iframe>
11. What are HTML forms, and what elements do they contain?
Answer: HTML forms allow users to input data. Common elements include:
<input>
– User input field<textarea>
– Multi-line text field<select>
– Dropdown list<button>
– Submit button
Example:
<form action="/submit" method="POST">
<input type="text" name="name" placeholder="Enter name">
<button type="submit">Submit</button>
</form>
12. What are new input types introduced in HTML5?
Answer:
email
– Validates email inputurl
– Validates URLsnumber
– Accepts numeric inputdate
– Displays a date pickerrange
– Creates a slider
Example:
<input type="email" placeholder="Enter your email">
<input type="date">
13. What is the purpose of the alt
attribute in images?
Answer: The alt
attribute provides alternative text for images, improving accessibility and SEO.
Example:
<img src="logo.png" alt="Company Logo">
14. What is the difference between absolute, relative, and root-relative URLs?
Answer:
URL Type | Example | Description |
---|---|---|
Absolute | https://example.com/page.html | Complete URL including domain |
Relative | page.html | Relative to the current page |
Root-relative | /folder/page.html | Starts from the website root |
15. What is the download
attribute in the <a>
tag?
Answer: It allows users to download a file instead of opening it.
Example:
<a href="file.pdf" download>Download PDF</a>
16. How do you create an HTML5 video player?
Answer:
<video controls>
<source src="video.mp4" type="video/mp4">
</video>
17. What is the difference between <b>
and <strong>
tags?
Answer:
<b>
– Bold text without extra emphasis.<strong>
– Bold text with semantic importance for search engines.
Example:
<b>Bold Text</b>
<strong>Important Text</strong>
This list of HTML interview questions for TCS covers fundamental and advanced topics to help you prepare effectively. 🚀