HTML Complete Tutorial Interview Guide

Beginner to Interview Preparation

What is HTML?

HTML (HyperText Markup Language) is the standard markup language used to create web pages. It provides the structure of a webpage.

Why HTML?

HTML Page Structure

<!DOCTYPE html>
<html>
<head>
 <title>My Website</title>
</head>
<body>
 Content
</body>
</html>   
Tag Purpose
DOCTYPE Tells browser HTML5 is used
html Root element
head Metadata
title Browser tab title
body Visible content

Important HTML Tags

Heading Tags

<h1>Heading 1</h1>

Heading 1

Paragraph Tag

<p>Hello World</p>

Hello World

Anchor Tag

<a href="https://google.com">Google</a>
Google

Image Tag

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

Formatting Tags

<b>Bold</b> <i>Italic</i> <u>Underline</u>
Bold Italic Underline

Lists

<ul><li>Apple</li></ul>

Table

<table>
  <tr>
    <th>Name</th>
    <th>Marks</th>
  </tr>
  <tr>
    <td>Ajay</td>
    <td>95</td>
  </tr>
</table>
Name Marks
Ajay 95
Arti 98

Forms

Text Input

<input type="text">

Radio Button

<input type="radio" name="gender">
Male Female

Checkbox

<input type="checkbox" /> 
<input type="checkbox" />
HTML CSS

Select

<select>
    <option>HTML</option>
    <option>CSS</option>
</select>

Textarea

<textarea rows="4"></textarea>

Semantic HTML

Semantic tags describe the meaning of content and improve SEO and accessibility.

Tag Purpose
header Top section
nav Navigation links
section Content section
article Independent content
aside Sidebar
footer Bottom section

Interview Questions with Answers

  1. What is HTML?
    HTML stands for HyperText Markup Language. It is used to create the structure of web pages.

  2. Is HTML a programming language?
    No. HTML is a markup language because it does not contain logic, loops, or functions.

  3. What is HTML5?
    HTML5 is the latest version of HTML that introduced semantic tags, audio, video, canvas, and local storage.

  4. Difference between div and span?
    div is a block-level element, while span is an inline element.

  5. Difference between id and class?
    id is unique; class can be used on multiple elements.

  6. What are semantic tags?
    Tags that clearly define their purpose, such as header, nav, section, and footer.

  7. What are empty tags?
    Tags without closing tags such as br, hr, img, and input.

  8. Difference between GET and POST?
    GET sends data through URL, POST sends data in the request body.

  9. Why use alt attribute?
    Provides alternative text if image fails to load and improves accessibility.

  10. Why use same name in radio buttons?
    To group radio buttons so only one option can be selected.

  11. What is the difference between HTML and CSS?

    HTML is used to create the structure of a webpage, while CSS is used to style and design the webpage.

  12. What is the difference between HTML and JavaScript?

    HTML creates structure, CSS adds design, and JavaScript adds interactivity and functionality.

  13. What is the purpose of the <head> tag?

    The head tag contains metadata such as title, CSS links, JavaScript files, and meta information.

  14. What is the purpose of the <body> tag?

    The body tag contains all visible content displayed on the webpage.

  15. What is the difference between block and inline elements?

    Block elements take the full width available and start on a new line. Inline elements only take the required width.

    Examples: div, p, h1 = Block Elements
    span, a, img = Inline Elements

  16. What is the difference between ul and ol?

    ul creates an unordered (bulleted) list while ol creates an ordered (numbered) list.

  17. What is the purpose of the alt attribute?

    The alt attribute provides alternative text when an image cannot be loaded and improves accessibility.

  18. What is an iframe?

    An iframe is used to embed another webpage inside the current webpage.

    <iframe src="page.html"></iframe>
    
  19. What is the difference between id and class?

    id is unique and should be used only once per page. class can be used for multiple elements.

  20. What are HTML entities?

    HTML entities are special codes used to display reserved characters.

    < = &lt;
    > = &gt;
    & = &amp;
    
  21. What is the purpose of the meta tag?

    The meta tag provides information about the webpage such as character encoding, author, and viewport settings.

  22. What is SEO in HTML?

    SEO (Search Engine Optimization) helps websites rank better in search engines using proper tags, headings, meta descriptions, and semantic HTML.

  23. What is the difference between strong and b?

    Both make text bold, but strong indicates importance while b only changes appearance.

  24. What is the difference between em and i?

    Both make text italic, but em adds semantic emphasis while i only changes appearance.

  25. What is a favicon?

    A favicon is the small icon displayed in the browser tab.

  26. What is the purpose of the title tag?

    The title tag defines the title shown in the browser tab and helps SEO.

  27. What are semantic tags?

    Semantic tags clearly describe the meaning of content. Examples include header, nav, section, article, aside, and footer.

  28. Why should semantic HTML be used?

    It improves readability, accessibility, SEO, and code maintenance.

  29. What is the difference between radio buttons and checkboxes?

    Radio buttons allow only one selection from a group. Checkboxes allow multiple selections.

  30. What is the purpose of the name attribute in forms?

    The name attribute identifies form data when submitted and is used to group radio buttons.

  31. What is the placeholder attribute?

    Placeholder displays temporary hint text inside input fields.

  32. What is the required attribute?

    It makes a form field mandatory before submission.

  33. What is HTML5 local storage?

    Local storage allows websites to store data in the user's browser without using a database.

  34. What are the new features of HTML5?

    HTML5 introduced:

    • Audio Tag
    • Video Tag
    • Canvas
    • Semantic Tags
    • Local Storage
    • Geolocation
  35. What is the canvas element?

    Canvas is used to draw graphics, charts, animations, and games using JavaScript.

  36. What is the difference between GET and POST?

    GET sends data in the URL and is less secure. POST sends data in the request body and is more secure.

  37. What is accessibility in HTML?

    Accessibility means designing websites that can be used by all people, including users with disabilities.

  38. Why is the label tag used?

    The label tag improves accessibility and allows users to click the label text to select form controls.

  39. What is the difference between section and div?

    section has semantic meaning while div is a generic container.

  40. What are empty tags?

    Empty tags do not have closing tags. Examples: br, hr, img, input, meta, link.