StackScholar
  • System Design Interview Preparation

    Beginner to advanced, with interactive simulators and full design case studies.

  • Python Full-Stack Interview Preparation

    Master backend + frontend questions with real-world cases.

  • AI/ML Engineer Interview Preparation

    ML, deep learning, LLMs, RAG, MLOps and system design - with mock interviews.

Rapid Review CSnewDSA VisualizerReviewBlog
Search⌘K
System Design Interview PreparationPython Full-Stack Interview PreparationAI/ML Engineer Interview Preparation
Rapid Review CSnewDSA VisualizerReviewBlog
CurriculumAll questionsFlashcardsGlossaryVisualizersDSA Visualizer

Navigate by Range

  • Q&A Python-1-5
  • Q&A Python-6-10
  • Q&A Python-11-15
  • Q&A Python-16-20
  • Q&A Python-21-25
  • Q&A Python-26-30
  • Q&A Python-31-35
  • Q&A Python-36-40
  • Q&A Python-41-45
  • Q&A Python-46-50
  • Q&A Python-51-55
  • Q&A Python-56-60
  • Q&A Python-61-65
  • Q&A Python-66-70
  • Q&A Python-71-75
  • Q&A Python-76-80
  • Q&A Python-81-85
  • Q&A Python-86-90
  • Q&A DB-MySQL-1-5
  • Q&A DB-MySQL-6-10
  • Q&A DB-MySQL-11-15
  • Q&A DB-MySQL-16-20
  • Q&A DB-MySQL-21-25
  • Q&A DB-MySQL-26-30
  • Q&A DB-MySQL-31-35
  • Q&A DB-MySQL-36-40
  • Q&A DB-MySQL-41-45
  • Q&A DB-MySQL-46-50
  • Q&A Django-1-5
  • Q&A Django-6-10
  • Q&A Django-11-15
  • Q&A Django-16-20
  • Q&A Django-21-25
  • Q&A Django-26-30
  • Q&A Django-31-35
  • Q&A Django-36-40
  • Q&A Django-41-45
  • Q&A Django-46-50
  • Q&A FastAPI-01-05
  • Q&A FastAPI-06-10
  • Q&A FastAPI-11-15
  • Q&A FastAPI-16-20
  • Q&A FastAPI-21-25
  • Q&A FastAPI-26-30
  • Q&A FastAPI-36-40
  • Q&A FastAPI-41-45
  • Q&A FastAPI-31-35
  • Q&A FastAPI-46-50
  • Q&A FastAPI-51-55
  • Q&A FastAPI-56-60
  • Q&A FastAPI-61-65
  • Q&A HTML-01-05
  • Q&A HTML-06-10
  • Q&A HTML-11-15
  • Q&A HTML-16-20
  • Q&A CSS-01-05
  • Q&A CSS-06-10
  • Q&A CSS-11-15
  • Q&A CSS-16-20
  • Q&A JavaScript-1-5
  • Q&A JavaScript-6-10
  • Q&A JavaScript-11-15
  • Q&A JavaScript-16-20
  • Q&A JavaScript-21-25
  • Q&A JavaScript-26-30
  • Q&A JavaScript-31-35
  • Q&A JavaScript-36-40
  • Q&A JavaScript-41-45
  • Q&A JavaScript-46-50
  • Q&A React-1-5
  • Q&A React-6-10
  • Q&A React-11-15
  • Q&A React-16-20
  • Q&A React-21-25
Loading…

Navigate by Range

  • Q&A Python-1-5
  • Q&A Python-6-10
  • Q&A Python-11-15
  • Q&A Python-16-20
  • Q&A Python-21-25
  • Q&A Python-26-30
  • Q&A Python-31-35
  • Q&A Python-36-40
  • Q&A Python-41-45
  • Q&A Python-46-50
  • Q&A Python-51-55
  • Q&A Python-56-60
  • Q&A Python-61-65
  • Q&A Python-66-70
  • Q&A Python-71-75
  • Q&A Python-76-80
  • Q&A Python-81-85
  • Q&A Python-86-90
  • Q&A DB-MySQL-1-5
  • Q&A DB-MySQL-6-10
  • Q&A DB-MySQL-11-15
  • Q&A DB-MySQL-16-20
  • Q&A DB-MySQL-21-25
  • Q&A DB-MySQL-26-30
  • Q&A DB-MySQL-31-35
  • Q&A DB-MySQL-36-40
  • Q&A DB-MySQL-41-45
  • Q&A DB-MySQL-46-50
  • Q&A Django-1-5
  • Q&A Django-6-10
  • Q&A Django-11-15
  • Q&A Django-16-20
  • Q&A Django-21-25
  • Q&A Django-26-30
  • Q&A Django-31-35
  • Q&A Django-36-40
  • Q&A Django-41-45
  • Q&A Django-46-50
  • Q&A FastAPI-01-05
  • Q&A FastAPI-06-10
  • Q&A FastAPI-11-15
  • Q&A FastAPI-16-20
  • Q&A FastAPI-21-25
  • Q&A FastAPI-26-30
  • Q&A FastAPI-36-40
  • Q&A FastAPI-41-45
  • Q&A FastAPI-31-35
  • Q&A FastAPI-46-50
  • Q&A FastAPI-51-55
  • Q&A FastAPI-56-60
  • Q&A FastAPI-61-65
  • Q&A HTML-01-05
  • Q&A HTML-06-10
  • Q&A HTML-11-15
  • Q&A HTML-16-20
  • Q&A CSS-01-05
  • Q&A CSS-06-10
  • Q&A CSS-11-15
  • Q&A CSS-16-20
  • Q&A JavaScript-1-5
  • Q&A JavaScript-6-10
  • Q&A JavaScript-11-15
  • Q&A JavaScript-16-20
  • Q&A JavaScript-21-25
  • Q&A JavaScript-26-30
  • Q&A JavaScript-31-35
  • Q&A JavaScript-36-40
  • Q&A JavaScript-41-45
  • Q&A JavaScript-46-50
  • Q&A React-1-5
  • Q&A React-6-10
  • Q&A React-11-15
  • Q&A React-16-20
  • Q&A React-21-25
StackScholar

StackScholar is your go-to destination for exploring technology from every angle - from bit to supercomputer.

Quick Links

  • Home
  • Search
  • Daily Review
  • Blog
  • About
  • Contact
  • Privacy Policy

DSA Visualizer

  • DSA Visualizer
  • Sorting Algorithms
  • Binary Search Tree
  • Dijkstra's Algorithm
  • A* Pathfinding
  • Dynamic Programming

Rapid Review CS

  • Rapid Review CS
  • Operating Systems
  • DBMS
  • Computer Networks
  • Data Structures & Algorithms
  • Computer Architecture

Interview Preparation

  • System Design Interview
  • System Design Toolkit
  • System Design Patterns
  • Python Full-Stack Interview
  • AI/ML Engineer Interview
  • ML Mock Interview
  • AI/ML Glossary

Get new lessons and visualizers in your inbox

Occasional email when something substantial ships. No spam, unsubscribe anytime.

© 2026 StackScholar. All rights reserved.

HTML Interview Questions 16-20 (Attributes, Links, Accessibility)

Welcome back! You have mastered the structure and the browser mechanics. Now, we are going to focus on precision and inclusivity.

In this lesson, we will clarify the subtle but strict differences between common attributes, learn how to attach hidden data to elements without cluttering the UI, and dive into Web Accessibility (a11y). Understanding these topics proves to an interviewer that you can build applications that are not just functional, but maintainable and usable by everyone.

16. What is the difference between id and class attributes?

Both attributes are used to select elements for styling (CSS) or interactivity (JavaScript), but they follow very different rules regarding uniqueness.

Analogy: Passport vs. Uniform
- ID: Like a Passport Number. It must be unique. Two people cannot have the same passport number in the same room.
- Class: Like a School Uniform. Many students can wear the exact same uniform at the same time.

FeatureID (#)Class (.)
Limit per PageOnly One element per page can have a specific ID.Unlimited elements can share the same Class.
Limit per ElementAn element can have only one ID.An element can have multiple classes (space-separated).
CSS SpecificityHigh specificity (overrides classes).Medium specificity.
JavaScriptgetElementById('name')getElementsByClassName('name')
<h1 id="main-title">Welcome</h1>

<button class="btn btn-primary">Login</button>
<button class="btn btn-secondary">Cancel</button>

17. What are data-* attributes and why are they used?

Standard attributes (like href or src) are defined by the HTML spec. But sometimes, you need to store custom data associated with an element-like a database ID, a price, or a user role-specifically for your JavaScript to use.

HTML5 introduced data attributes. They must start withdata- followed by your custom name.

How to use them:
In JavaScript, you access them via the dataset property. The browser automatically converts kebab-case (data-user-id) to camelCase (dataset.userId).

<div id="product-card" data-id="101" data-category="electronics" data-price="499">
  Smartphone X
</div>

<script>
  const card = document.getElementById("product-card");
  
  // Accessing data
  const productId = card.dataset.id;      // "101"
  const category = card.dataset.category; // "electronics"
  
  console.log(`User clicked product ${productId} in ${category}`);
</script>

Sample Output (Console):
User clicked product 101 in electronics

18. What is the purpose of the <link> tag in HTML?

The <link> tag is an empty (self-closing) element used to define a relationship between the current document and an external resource. It almost always lives in the <head>.

While it is most famous for loading CSS, it has several other powerful uses for performance and branding.

  • 1. Stylesheets: The most common usage.
    <link rel="stylesheet" href="style.css">
  • 2. Favicons: The small icon in the browser tab.
    <link rel="icon" href="favicon.ico">
  • 3. Preloading (Performance): Tells the browser to start downloading a resource (like a font) immediately, even before it parses the rest of the HTML.
    <link rel="preload" href="font.woff2" as="font">

19. What is the role of ARIA attributes in accessible HTML?

ARIA (Accessible Rich Internet Applications) is a set of attributes that make web content and applications more accessible to people with disabilities using screen readers.

The Golden Rule of ARIA:
"No ARIA is better than bad ARIA." Always prefer native semantic HTML elements first. Only use ARIA when HTML tags cannot describe the behavior of your component (like a complex custom dropdown or a popup modal).

  • aria-label: Provides an invisible label for an element that has no text (like an icon button).
  • role: Tells the screen reader what the element is (e.g., role="alert").
  • aria-hidden: Tells the screen reader to ignore an element (useful for decorative icons).
<button><i class="fa fa-times"></i></button>

<button aria-label="Close">
  <i class="fa fa-times" aria-hidden="true"></i>
</button>

20. What is the difference between iframe and embed tags?

Both tags allow you to bring external content into your webpage, but they serve different historical and practical purposes.

TagPrimary UseClosing Tag?
<iframe>Embedding other HTML pages (Maps, YouTube, Ads). It creates a "nested browsing context".Yes (</iframe>)
<embed>Embedding non-HTML resources via plugins (PDFs, older Flash). Mostly obsolete for media.No (Self-closing)

Modern Usage:
You will use <iframe> 99% of the time. It is standard for embedding third-party content like YouTube videos or Google Maps. <embed> is largely replaced by<audio>, <video>, or <object>.

<iframe 
  width="560" 
  height="315" 
  src="https://www.youtube.com/embed/dQw4w9WgXcQ" 
  title="YouTube video player" 
  border="0">
</iframe>

Check your understanding

3 questions · no sign-up, nothing stored

0/3 answered
Question 1

1.What is the first rule of ARIA?

Question 2

2.When should you use an id rather than a class?

Question 3

3.What are data-* attributes for?

0 / 74 ranges

Progress is stored in this browser only - no sign-up, nothing sent anywhere.

PreviousNext