← Chrome 160 reference · All APIs

v160 · dom · enabled by default

Case-sensitive anchor name matching in quirks mode

Fragment navigation in quirks-mode HTML documents (document.compatMode === "BackCompat") now matches <a name="…"> attributes using exact case-sensitive code-unit comparison, matching standards mode, Firefox, Safari, and the HTML Living Standard. Navigating to #Foo no longer scrolls to or sets :target on <a name="foo">.

No web-features Baseline ID — interoperable across Chrome 160, Firefox, and Safari

  • Chrome · 160 (desktop, Android, WebView)
  • Edge · Chromium-based (follows M160 rollout)
  • Firefox · Already case-sensitive (per ChromeStatus)
  • Safari · Already case-sensitive (per ChromeStatus)

There is no dedicated web-feature ID on webstatus.dev (ChromeStatus records web_feature: "Missing feature"). BCD html/elements/a.json documents the deprecated <a name> attribute across all browsers but has no separate subfeature for quirks-mode case sensitivity (checked 2026-11-24).

at a glance

Shipped inChrome 160 (desktop, Android, Android WebView), enabled by default — listed under “Enabled by default” in the milestone=160 listing and confirmed in the ChromeStatus API record
Kill switch / flagNo origin trial, no user-facing chrome://flags toggle. Blink runtime flag CaseSensitiveAnchorMatching is status: "stable" in runtime_enabled_features.json5 (kill switch planned for removal in M162; emergency rollback via --disable-blink-features=CaseSensitiveAnchorMatching)
SpecificationHTML Living Standard — find a potential indicated element & the indicated part of the document
Tracking bugissues.chromium.org/40829784
TelemetryUseCounter 5784 (AnchorCaseSensitiveMatch); UseCounter 5785 (AnchorCaseInsensitiveMatch) (~0.00015% of page loads)
Web platform testswpt.fyi — scroll-to-anchor-name-quirks-case.html (WPT source)
ChromeStatus5085237991309312 — Case-sensitive anchor name matching in quirks mode

why it exists

In quirks mode (pages rendered without a standards <!doctype html> declaration, where document.compatMode === "BackCompat"), Chromium previously ran a legacy case-insensitive fallback (DeprecatedEqualIgnoringCase) when resolving URL fragments against <a name="…"> elements. Neither Firefox, Safari, nor the HTML Living Standard perform case-insensitive anchor name matching in quirks mode. Worse, Chromium’s single-pass tree traversal could let an earlier case-mismatched <a name="Destination"> shadow a later exact <a name="destination">. With telemetry showing the fallback fired on only ~0.00015% of page loads, Chrome 160 removes it to achieve cross-browser interoperability.

Source: ChromeStatus motivation & compat risks (5085237991309312); Blink tree_scope.cc.

Syntax

No new HTML element, attribute, or JavaScript API syntax is introduced. This change updates fragment-identifier resolution against the existing (obsolete in HTML5) <a name="…"> attribute in quirks-mode documents (document.compatMode === "BackCompat") and aligns it with case-sensitive id matching:

<!-- Quirks-mode HTML document (no <!doctype html>): document.compatMode === "BackCompat" -->
<a name="section-Alpha"></a>

<!-- Fragment link & CSS :target matching -->
<a href="#section-Alpha">Matches (exact case)</a>
<a href="#section-alpha">Does NOT match in Chrome 160+</a>

<!-- Preferred modern replacement (case-sensitive in all modes) -->
<section id="section-Alpha">...</section>

“To find a potential indicated element given a Document document and a string fragment, run these steps: 1. If there is an element in the document tree whose root is document and that has an ID equal to fragment, then return the first such element in tree order. 2. If there is an a element in the document tree whose root is document that has a name attribute whose value is equal to fragment, then return the first such element in tree order. 3. Return null.”

This reference covers both parts of the Chrome 160 change: the case-sensitive quirks-mode <a name> fragment lookup algorithm and migrating quirks-mode documents from case-mismatched name anchors to exact-case or id targets.

Source: HTML Living Standard — find a potential indicated element (fetched 2026-11-24); HTML Living Standard — obsolete a name attribute.

Quirks-mode fragment lookup — inputs and outputs

Inputs. A quirks-mode HTML Document (document.compatMode === "BackCompat") and a URL fragment string (from initial navigation, clicking <a href="#…">, assigning location.hash, or history traversal).

Outputs. Returns the indicated DOM node (updating CSS :target and scrolling the element into view), the special value top of the document, or null (clearing :target with no scroll). Per the HTML specification and Blink’s TreeScope::FindAnchor() / FindAnchorWithName():

  1. If the raw fragment is the empty string "", return the top of the document.
  2. Look up the raw fragment via FindAnchorWithName(fragment): first check getElementById(fragment) (always exact case-sensitive), then scan <a> elements in tree order for an exact code-unit match anchor.getAttribute("name") === fragment.
  3. If step 2 returns null, percent-decode the fragment as UTF-8 without BOM to produce decodedFragment and run FindAnchorWithName(decodedFragment) again using exact case-sensitive matching.
  4. If still null and decodedFragment is an ASCII case-insensitive match for "top" (for example #TOP or #Top), return the top of the document. (This special #top rule is unchanged.)
  5. Otherwise return null.
Quirks-mode (BackCompat) fragment matching before vs in Chrome 160+ (from WPT scroll-to-anchor-name-quirks-case.html)
Anchor markup in quirks modeFragmentChrome ≤ 159Chrome 160+ / Firefox / Safari
<a name="sample_é">#sample_éMatchesMatches
<a name="sample_é">#SAMPLE_é (ASCII case mismatch)Matched (fallback)null (no match)
<a name="sample_é">#sample_É (non-ASCII case mismatch)Matched (fallback)null (no match)
<a name="sample_é">#ſample_é (U+017F Unicode fold)Matched (fallback)null (no match)
<a name="Destination"> then <a name="destination">#destinationMatched earlier DestinationMatches exact destination
Any document (no matching id/name)#TOPTop of documentTop of document (unchanged)
Source: WPT scroll-to-anchor-name-quirks-case.html; Blink tree_scope.cc (FindAnchorWithName); HTML Living Standard.

Errors, silent misses, and migration

Error behavior. A case-mismatched fragment does not throw a JavaScript exception or log a console error. Assigning location.hash = "#Foo" still updates the URL and fires hashchange, but document.querySelector(":target") becomes null and the browser does not scroll to <a name="foo">.

Migration steps for legacy quirks-mode pages (document.compatMode === "BackCompat"):

Source: ChromeStatus activation_risks & interop_compat_risks; Blink runtime_enabled_features.json5; HTML Living Standard — obsolete a name.

Context and exposure

This behavior applies to HTML documents rendered in quirks mode (document.compatMode === "BackCompat") in any top-level browsing context or <iframe> on desktop, Android, and Android WebView. Standards mode (CSS1Compat) and limited-quirks mode already performed case-sensitive id and <a name> lookup. Fragment lookup operates within the document’s own tree scope (TreeScope); elements inside shadow trees are not matched by document fragment navigation. No secure context, permission, or JavaScript is required.

Source: HTML Living Standard — find a potential indicated element; Blink tree_scope.cc.

Lifecycle and timing

Fragment anchor resolution runs whenever the browser navigates to a URL containing a fragment, clicks a same-document fragment link, updates location.hash, or traverses session history entries with fragments. On each resolution, the document updates its target element (observable immediately via document.querySelector(":target")) and scrolls the indicated element into view if found. Removing the case-insensitive fallback also guarantees that an earlier case-mismatched <a name> in tree order cannot preempt a later exact-case <a name>.

Source: HTML Living Standard — the indicated part of the document; WPT scroll-to-anchor-name-quirks-case.html.

Examples

No live demo exists yet on the Chrome Platform Showcase for this feature.

Quirks-mode fragment matching in Chrome 160+

<!-- Intentionally missing <!doctype html> so document.compatMode === "BackCompat" -->
<html>
<head><meta charset="utf-8"></head>
<body>
  <a name="sample_é" id="anchor">Exact target</a>
  <a name="Destination" id="earlier-anchor">Different case</a>
  <a name="destination" id="exact-anchor">Exact lowercase</a>

  <script>
    console.assert(document.compatMode === "BackCompat");

    // 1. Exact case matches:
    location.hash = "#sample_é";
    document.querySelector(":target")?.id; // "anchor"

    // 2. ASCII, non-ASCII, and Unicode case-fold mismatches all return null:
    location.hash = "#SAMPLE_é";
    document.querySelector(":target"); // null

    location.hash = "#sample_É";
    document.querySelector(":target"); // null

    location.hash = "#\u017Fample_é"; // U+017F long s
    document.querySelector(":target"); // null

    // 3. Earlier case-mismatched <a name="Destination"> no longer hides exact match:
    location.hash = "#destination";
    document.querySelector(":target")?.id; // "exact-anchor"
  </script>
</body>
</html>
Source: Adapted from WPT scroll-to-anchor-name-quirks-case.html.

Auditing quirks-mode pages for case-mismatched <a name> links

// Run in DevTools or automated checks on legacy quirks-mode pages:
function findCaseMismatchedFragmentLinks() {
  if (document.compatMode !== "BackCompat") return [];

  const exactIds = new Set([...document.querySelectorAll("[id]")].map((el) => el.id));
  const anchorNames = [...document.querySelectorAll("a[name]")]
    .map((a) => a.getAttribute("name"))
    .filter(Boolean);
  const exactNames = new Set(anchorNames);
  const lowerNames = new Map(anchorNames.map((n) => [n.toLowerCase(), n]));

  const broken = [];
  for (const link of document.querySelectorAll('a[href^="#"]')) {
    const raw = link.getAttribute("href").slice(1);
    if (!raw || raw.toLowerCase() === "top") continue;
    const decoded = decodeURIComponent(raw);
    if (exactIds.has(raw) || exactIds.has(decoded)) continue;
    if (exactNames.has(raw) || exactNames.has(decoded)) continue;

    const matchedName = lowerNames.get(raw.toLowerCase()) ?? lowerNames.get(decoded.toLowerCase());
    if (matchedName) {
      broken.push({ href: link.getAttribute("href"), expectedName: matchedName, link });
    }
  }
  return broken;
}

// Recommended fix: add <!doctype html> and replace <a name="faq"> with <h2 id="faq">
Source: Derived from HTML Living Standard fragment lookup steps and ChromeStatus 5085237991309312 migration notes.

Browser compatibility

Case-sensitive <a name> matching in quirks mode. BCD has no subfeature for quirks-mode anchor case sensitivity; status comes from ChromeStatus, Blink source, and wpt.fyi (checked 2026-11-24). The deprecated <a name> column is from BCD.
BrowserCase-sensitive in quirks modeEvidence / notes<a name> attribute (BCD)
Chrome (desktop, Android, WebView)160CaseSensitiveAnchorMatching set to status: "stable" for M160 per ChromeStatus 5085237991309312 and runtime_enabled_features.json51 (deprecated)
Edge160 (expected)Chromium-based (feature authored by Microsoft engineers); wpt.fyi Edge 160.0.4408.0 recorded 2/6 prior to stable flag flip (checked 2026-11-24)12 (deprecated)
FirefoxShippedAlready case-sensitive in quirks mode per ChromeStatus (exact historical version unrecorded in BCD)1 (deprecated)
SafariShippedAlready case-sensitive in quirks mode per ChromeStatus (exact historical version unrecorded in BCD)1 (deprecated)
Source: BCD html/elements/a.json; ChromeStatus API record; wpt.fyi results.

Security and privacy

ChromeStatus 5085237991309312 records security_risks: "None" and marks Security and Privacy reviews Not applicable. Removing Chromium’s legacy case-insensitive fallback in quirks mode introduces no new storage, permission, or cross-origin channel; it narrows fragment matching to exact code-unit equality and removes an ambiguity where an earlier case-mismatched <a name> element could intercept :target styling and scroll focus intended for an exact-case anchor.

Source: ChromeStatus 5085237991309312; HTML Living Standard.

Specifications

see also