HTML Interview Questions and Answers


🔹 1. What is HTML?

HTML (HyperText Markup Language) is the standard language used to create web pages. It defines the structure of a webpage using elements like headings, paragraphs, links, images, and forms.


🔹 2. What are HTML elements?

HTML elements are building blocks of a webpage. They usually consist of:

  • Opening tag
  • Content
  • Closing tag

Example:

<p>This is a paragraph</p>

🔹 3. What are HTML attributes?

Attributes provide extra information about elements.

Example:

<a href="https://example.com">Click here</a>

🔹 4. What is the difference between HTML and HTML5?

HTML5 is the latest version with new features like:

  • Audio and video support
  • Semantic tags
  • Better APIs
  • Mobile-friendly design

🔹 5. What are semantic elements?

Semantic elements clearly describe their meaning.

Examples:

  • <header>
  • <footer>
  • <article>
  • <section>

🔹 6. Why are semantic tags important?

They improve:

  • SEO ranking
  • Accessibility
  • Code readability

🔹 7. What is DOCTYPE in HTML?

It defines the HTML version used in the document.

Example:

<!DOCTYPE html>

🔹 8. What is the difference between div and span?

divspan
Block elementInline element
Used for layoutUsed for styling text

🔹 9. What is a form in HTML?

A form is used to collect user input like name, email, password, etc.


🔹 10. What are input types?

Common input types:

  • text
  • password
  • email
  • number
  • radio
  • checkbox

🔹 11. Difference between GET and POST?

GETPOST
Sends data in URLSends data in body
Less secureMore secure

🔹 12. What is an iframe?

It is used to embed another webpage inside a webpage.


🔹 13. What is alt attribute?

It provides alternative text for images.


🔹 14. Why is alt important?

  • Improves SEO
  • Helps screen readers
  • Shows text if image fails

🔹 15. What is a meta tag?

Meta tags provide metadata like description, keywords, viewport settings.


🔹 16. What is HTML5?

HTML5 is the latest version of HTML with advanced features like multimedia support and better structure.


🔹 17. What are block elements?

Block elements take full width of the page.

Examples:

  • div
  • p
  • h1

🔹 18. What are inline elements?

Inline elements take only required space.

Examples:

  • span
  • a
  • strong

🔹 19. Difference between block and inline elements?

BlockInline
Full widthLimited width
Starts new lineSame line

🔹 20. What is HTML structure?

Basic structure:

<html>
<head>
<title>Page</title>
</head>
<body>
Content here
</body>
</html>

🔹 21. What is nesting in HTML?

Placing one element inside another element.


🔹 22. What is accessibility in HTML?

Making websites usable for all users, including disabled users.


🔹 23. What is ARIA?

Accessible Rich Internet Applications attributes used for accessibility.


🔹 24. What is the use of <head> tag?

It contains metadata, title, links, and scripts.


🔹 25. What is the use of <body> tag?

It contains visible content of the webpage.


🔹 26. What is hyperlink?

A link that connects one page to another using <a> tag.


🔹 27. What is image tag?

Used to display images.

<img src="image.jpg" alt="image">

🔹 28. What is table in HTML?

Used to display data in rows and columns.


🔹 29. What are table tags?

  • <table>
  • <tr>
  • <td>
  • <th>

🔹 30. What is list in HTML?

Used to display items.

Types:

  • Ordered list <ol>
  • Unordered list <ul>

🔹 31. What is difference between ol and ul?

olul
Numbered listBullet list

🔹 32. What is favicon?

Small icon shown in browser tab.


🔹 33. What is HTML form validation?

Checking user input before submitting.


🔹 34. What is placeholder?

Hint text inside input field.


🔹 35. What is required attribute?

Makes input mandatory.


🔹 36. What is button tag?

Used to create clickable buttons.


🔹 37. What is label tag?

Used to describe form elements.


🔹 38. What is difference between id and class?

idclass
UniqueReusable
# symbol. symbol

🔹 39. What is script tag?

Used to include JavaScript.


🔹 40. What is link tag?

Used to connect CSS file.


🔹 41. What is SEO in HTML?

Optimizing webpage for search engines.


🔹 42. What is viewport meta tag?

Makes website responsive on mobile.


🔹 43. What is character encoding?

Defines how characters are displayed (UTF-8).


🔹 44. What is comment in HTML?

Used to write notes:

<!-- This is a comment -->

🔹 45. What is deprecated tag?

Old HTML tags no longer recommended.


🔹 46. What is canvas?

Used for drawing graphics using JavaScript.


🔹 47. What is audio tag?

Used to embed sound files.


🔹 48. What is video tag?

Used to embed videos.


🔹 49. What is embed tag?

Used to embed external content.


🔹 50. Why HTML is important?

It is the foundation of all web pages.