MyInternships.in

HTML5

Are HTML5 Tags Case Sensitive?

A common interview question is whether HTML5 tags are case sensitive. The short answer is no: HTML5 tag and attribute names are case-insensitive, meaning the browser treats <DIV>, <Div>, and <div> as exactly the same element. However, writing tags in lowercase is the strongly recommended best practice.


Direct Answer

HTML5 tag names are NOT case sensitive. The parser normalises element and attribute names to lowercase internally, so <H1>Hello</H1> and <h1>Hello</h1> produce the identical result. This is different from XHTML, which required lowercase, and from languages like XML and JavaScript, which are strictly case sensitive.

Runnable Example

Mixed-case tags render identically to lowercase ones
Example
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Case Sensitivity Demo</title>
</head>
<body>
  <H1>Uppercase H1 tag</H1>
  <h1>Lowercase h1 tag</h1>
  <P>Both headings above look and behave the same.</P>
  <DiV>Even mixed-case DiV works fine.</DiV>
</body>
</html>

What Actually IS Case Sensitive?

Part of HTMLCase Sensitive?
Tag names (<div>, <p>)No
Attribute names (class, href)No
Attribute values in generalDepends (usually significant)
id and class valuesYes — must match exactly in CSS/JS
File paths / URLs in src, hrefYes on most servers
⚠️

While tag names are case-insensitive, the VALUES of id and class attributes ARE case sensitive. <div id="Main"> and #main in CSS will not match.

Why Use Lowercase?

  • Lowercase is the universal community and style-guide standard.
  • It improves readability and consistency across a codebase.
  • It is required if you ever serve documents as XHTML/XML.
  • Linters and formatters (like Prettier) expect and enforce it.

Key Takeaways

  • HTML5 tag and attribute names are case-insensitive.
  • Always write tags in lowercase as best practice.
  • id and class VALUES remain case sensitive.

Related HTML Topics

Keep learning with these closely related tutorials.

Ready to use your HTML skills?

Find web development internships and fresher jobs across India.

Browse Web Dev Internships