Skip to main content
InterviewHubPRO
Section Overview
Q12

Question 12 of 50

Part 1: Basic & Foundational Concepts (Junior / Entry-Level)

24%
HTML5 & Web APIs (50 Qs)•Part 1: Basic & Foundational Concepts (Junior / Entry-Level)

What is the difference between `id`, `class`, and `name` attributes?

junior LevelhtmlBasic

In Simple Words:

  • id: Unique identifier for an element. Must be unique across the entire DOM. Used for anchor links (#section-1), form label associations (<label for="email">), and JavaScript lookups (document.getElementById).
  • class: Non-unique identifier shared across multiple elements for CSS styling and DOM querying (document.querySelectorAll('.card')).
  • name: The key submitted in HTTP form payloads (?name=value). Also groups radio buttons together so only one can be checked at a time.