Top 250 HTML Interview Questions and Answers

Updated 16 Jul 2025

Asked in Cognizant

1d ago

Q. How do you get the count of all text boxes on a webpage?

Ans.

Use Selenium WebDriver to find and count all text boxes on a web page.

  • Use Selenium WebDriver to locate all text boxes on the web page

  • Use findElements method with input tag and type attribute as text to find all text boxes

  • Get the size of the list of e...read more

Asked in idoow

5d ago

Q. How is JavaScript used in HTML?

Ans.

JavaScript in HTML is a scripting language used to add interactivity and dynamic content to web pages.

  • JavaScript is a programming language that can be embedded directly into HTML code

  • It allows for interactive elements like pop-up alerts, form validat...read more

Q. What is an embedded style sheet?

Ans.

Embedded style sheet is CSS code written within the <style> tag in the head section of an HTML document.

  • Embedded style sheet is used to define styles for a single HTML document.

  • It is written within the <style> tag in the head section of the HTML docu...read more

Asked in Imaginnovate

1d ago

Q. How do we link external CSS and JS files to HTML?

Ans.

External CSS and JS files can be linked to HTML using the <link> and <script> tags respectively.

  • Use the <link> tag with the 'rel' attribute set to 'stylesheet' to link external CSS files.

  • Use the <script> tag with the 'src' attribute to link external ...read more

Are these interview questions helpful?
4d ago

Q. In HTML, is span a tag?

Ans.

Yes, span is a tag in HTML used to apply styles to inline elements.

  • Span is an inline element used to apply styles to a specific section of text or content.

  • It does not add any extra space or line breaks.

  • Example: <span style='color: red;'>This text wil...read more

Asked in Entrata and 9 others

4d ago

Q. What is the difference between sessions and cookies?

Ans.

Sessions store data on the server side while cookies store data on the client side.

  • Sessions store data on the server side, usually in a temporary directory or database

  • Cookies store data on the client side, in the form of key-value pairs

  • Sessions are m...read more

Share interview questions and help millions of jobseekers 🌟
man with laptop

Asked in Webskitters

6d ago

Q. What is the difference between and tags?

Ans.

The <b> tag is used to bold text, while the <strong> tag is used to emphasize text with stronger importance.

  • The <b> tag is used for stylistic purposes, while the <strong> tag is used for semantic purposes.

  • The <b> tag is purely presentational, while t...read more

Asked in Atos

1d ago

Q. How many windows can be maintained under one page?

Ans.

The number of windows that can be maintained under one page depends on the system's capabilities and resources.

  • The number of windows that can be maintained may vary based on the operating system and hardware specifications.

  • Factors such as memory, pro...read more

Asked in Infosys

4d ago

Q. How can JavaScript be embedded in CSS?

Ans.

JavaScript cannot be embedded directly in CSS, but can be used in conjunction with CSS to manipulate styles dynamically.

  • JavaScript can be used to dynamically change CSS properties of elements on a webpage

  • This can be achieved by selecting the element ...read more

Asked in Axioned

3d ago

Q. What is the difference between a block element and an inline element?

Ans.

Block elements take up the full width available, while inline elements only take up as much width as necessary.

  • Block elements start on a new line and stack vertically, while inline elements flow within the text.

  • Block elements can have margins and pad...read more

HTML Jobs

DHL Global Forwarding India logo
Senior Manager- Finance 12-15 years
DHL Global Forwarding India
4.2
Mumbai
DHL Global Forwarding India logo
Senior Manager- BD- Service Logistics 5-10 years
DHL Global Forwarding India
4.2
₹ 19 L/yr - ₹ 29 L/yr
(AmbitionBox estimate)
Hubli
DHL Global Forwarding India logo
Senior Software Engineer 5-10 years
DHL Global Forwarding India
4.2
Chennai
1d ago

Q. What are the differences between XML and HTML?

Ans.

XML is used for storing and transporting data, while HTML is used for displaying data on web pages.

  • XML is extensible and allows users to define their own tags, while HTML has predefined tags for structuring content.

  • XML focuses on data and its structu...read more

5d ago

Q. What is the use of meta tags in HTML?

Ans.

Meta tags in HTML are used to provide metadata about the HTML document.

  • Meta tags are placed in the head section of an HTML document.

  • They provide information such as character set, viewport settings, keywords, and description.

  • Meta tags can also be use...read more

Asked in Houzeo

4d ago

Q. What are semantic and meta tags in a webpage?

Ans.

Semantic and meta tags in a webpage help search engines understand the content and structure of the page.

  • Semantic tags provide meaning to the content, such as <header>, <footer>, <article>, <section>.

  • Meta tags provide metadata about the webpage, such...read more

Q. What is the tag for an anchor link in HTML?

Ans.

The tag for Anchor link in HTML is <a>

  • The anchor tag is used to create hyperlinks in HTML

  • The href attribute is used to specify the URL of the page the link goes to

  • Text between the opening and closing <a> tags is the clickable text for the link

Asked in HARMAN

3d ago

Q. How do you add an image using the image tag?

Ans.

To add an image in an image tag, use the 'src' attribute with the URL of the image.

  • Use the <img> tag in HTML

  • Set the 'src' attribute to the URL of the image

  • Optionally, add 'alt' attribute for accessibility

1d ago
Q. What are the new tags for media elements introduced in HTML5?
Ans.

New tags in Media Elements in HTML5 include <audio> and <video>.

  • <audio> tag for audio content

  • <video> tag for video content

  • Attributes like controls, autoplay, loop, etc. can be used with these tags

3d ago

Q. If both id and class are applied to an element, which style will take precedence?

Ans.

The style of the id will apply first before the style of the class.

  • IDs have higher specificity than classes, so the style of the id will take precedence over the style of the class.

  • If both id and class have conflicting styles, the style of the id wil...read more

Asked in MAQ Software

5d ago

Q. What is the difference between span and div tags?

Ans.

Span is an inline element used for styling small portions of text, while div is a block-level element used for grouping and styling larger sections of content.

  • Span is an inline element, div is a block-level element

  • Span is used for styling small porti...read more

1d ago

Q. What is the span tag in HTML?

Ans.

The span tag in HTML is used to group inline elements and apply styles to them.

  • Used to group inline elements together

  • Does not add any extra space or line breaks

  • Commonly used for styling purposes

Asked in MagicBricks

2d ago

Q. Tell me the difference between Semantic and Nonsemantic elements

Ans.

Semantic elements provide meaning to the content, while nonsemantic elements are used for styling purposes only.

  • Semantic elements have a clear meaning and purpose in the code, making it easier for search engines and screen readers to understand the c...read more

Asked in CitiusTech

2d ago

Q. What different HTML attributes have you used so far?

Ans.

I have used various HTML attributes such as id, class, src, href, alt, style, etc.

  • id

  • class

  • src

  • href

  • alt

  • style

Asked in CyberSafex and 2 others

6d ago

Q. What is the difference between span and div?

Ans.

Span is an inline element used for styling small portions of text, while div is a block-level element used for grouping and styling larger sections of content.

  • Span is an inline element, while div is a block-level element

  • Span is used for styling small...read more

6d ago

Q. What are heading tags?

Ans.

Heading tags are HTML elements used to define headings and subheadings on a webpage.

  • Heading tags range from <h1> to <h6>, with <h1> being the most important and <h6> the least important.

  • Heading tags help search engines understand the structure and co...read more

Asked in Webskitters

5d ago

Q. What is the difference between DIV and SPAN tags?

Ans.

DIV is a block-level element while SPAN is an inline element used for styling and grouping content.

  • DIV is a block-level element, meaning it takes up the full width available and starts on a new line.

  • SPAN is an inline element, meaning it only takes up...read more

Asked in TCS

2d ago

Q. How can you display an IP address in HTML?

Ans.

Use JavaScript to display the user's IP address on an HTML page.

  • Use JavaScript to fetch the user's IP address

  • Create a HTML element to display the IP address

  • Insert the fetched IP address into the HTML element

Asked in PurpleTalk and 2 others

1d ago

Q. What is the Marquee tag?

Ans.

The Marquee tag is an HTML element used to create scrolling text or images on a web page.

  • The <marquee> tag is used to create a scrolling effect horizontally or vertically.

  • It has attributes like behavior, direction, scrollamount, scrolldelay, etc.

  • Exam...read more

Asked in Indegene

5d ago

Q. Why do you use doctype in HTML?

Ans.

Doctype in HTML specifies the version of HTML being used and helps browsers render web pages correctly.

  • Specifies the version of HTML being used

  • Helps browsers render web pages correctly

  • Prevents browsers from entering quirks mode

Asked in Moris Media

1d ago

Q. What is the purpose of an hreflang tag?

Ans.

An hreflang tag is used to indicate to search engines the language and geographical targeting of a webpage.

  • Helps search engines understand the language and geographical targeting of a webpage

  • Improves international SEO by serving the correct language ...read more

2d ago

Q. What does DOCTYPE mean?

Ans.

DOCTYPE is an instruction to the web browser about the version of HTML being used in the document.

  • DOCTYPE declaration is placed at the very beginning of an HTML document, before the <html> tag.

  • It helps the browser to render the web page correctly by ...read more

Asked in Kiaan Technology and 12 others

3d ago

Q. What is the Box Model?

Ans.

Box Model is a concept in CSS where every element is treated as a box with content, padding, border, and margin.

  • Box Model consists of content, padding, border, and margin.

  • Content is the actual content of the box.

  • Padding is the space between the conte...read more

1
2
3
4
5
6
7
Next

Interview Experiences of Popular Companies

TCS Logo
3.6
 • 11.1k Interviews
Accenture Logo
3.7
 • 8.7k Interviews
Infosys Logo
3.6
 • 7.9k Interviews
Wipro Logo
3.7
 • 6.1k Interviews
Cognizant Logo
3.7
 • 5.9k Interviews
Amazon Logo
4.0
 • 5.4k Interviews
Capgemini Logo
3.7
 • 5.1k Interviews
HCLTech Logo
3.5
 • 4.1k Interviews
LTIMindtree Logo
3.7
 • 3k Interviews
AmbitionBox Logo
4.8
 • 150 Interviews
View all
Interview Tips & Stories
Interview Tips & Stories
Ace your next interview with expert advice and inspiring stories
HTML Interview Questions
Share an Interview
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
Trusted by over 1.5 Crore job seekers to find their right fit company
80 Lakh+

Reviews

10L+

Interviews

4 Crore+

Salaries

1.5 Cr+

Users

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2025 Info Edge (India) Ltd.

Follow Us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter
Profile Image
Hello, Guest
AmbitionBox Employee Choice Awards 2025
Winners announced!
awards-icon
Contribute to help millions!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos
Add office benefits
Add office benefits