Engineering / Field note
A wrapped link's rectangle can include a gap
Five fictional browser examples separate a wrapped link's enclosing rectangle, its line fragments and actual activation. A point inside the box may still miss the link.
A wrapped link can occupy two lines while the middle of its enclosing rectangle falls between them. A test that measures one box, clicks its center and expects navigation can therefore miss a perfectly ordinary inline link. The rectangle is useful; the assumption about everything inside it needs another check. The box has room for some unlinked air.
This field note reviews established browser behavior on December 2, 2026. It concerns HTML links in a controlled, fictional page, rather than a newly disclosed browser vulnerability. The five original examples separate enclosing geometry, individual line fragments, the element under a point and actual navigation.
Start with a link that wraps
MDN documents getClientRects as returning a rectangle for each CSS border box associated with an element. A multiline inline element can have a separate box around each line. By comparison, getBoundingClientRect returns the smallest rectangle enclosing the element's boxes. That enclosing rectangle can span the spaces between line fragments. [1] [2]
Load the following complete miniature document in a browser. Its narrow navigation container and generous line height deliberately make the link wrap. The destination is a fragment in the same fictional document. No external service, account or real website is involved.
<!doctype html>
<meta charset="utf-8">
<title>Fictional link fixture</title>
<style>
body { margin: 0; font: 16px/2.5 monospace; }
.demo-toc { width: 180px; margin: 32px; }
#chapter { margin-top: 160px; }
</style>
<nav class="demo-toc" aria-label="Fictional guide">
<a id="demo-link" href="#chapter">Open the fictional handbook</a>
</nav>
<h2 id="chapter">Fictional chapter</h2>Our initial Chromium fixture produces two line fragments. The center of the enclosing rectangle lies below the first fragment and above the second. Both measurements accurately describe the page; they answer different questions.
Check the point before assigning it meaning
The next example measures both representations and tests whether the enclosing center belongs to either fragment. It also asks the browser which element occupies that point. The assertion deliberately expects the gap in this fixture, making the tempting center-click assumption visible and reproducible.
const link = document.querySelector("#demo-link");
const box = link.getBoundingClientRect();
const point = {
x: box.left + box.width / 2,
y: box.top + box.height / 2,
};
const fragments = [...link.getClientRects()]
.filter(r => r.width > 0 && r.height > 0);
const insideFragment = fragments.some(r =>
point.x >= r.left && point.x < r.right
&& point.y >= r.top && point.y < r.bottom
);
const hit = document.elementFromPoint(point.x, point.y);
const linkOwnsPoint = hit === link || link.contains(hit);
if (fragments.length < 2 || insideFragment || linkOwnsPoint) {
throw new Error("Expected the fictional link's central gap");
}MDN describes document.elementFromPoint as returning the topmost element at viewport-relative coordinates. Elements with pointer-events set to none are skipped, and a point outside the visible document can return null. This is a hit-test observation, so its result can differ from an element's bounding rectangle. [3]
In our fixture the point belongs to the surrounding navigation element. Sending a real browser pointer click there leaves the location fragment unchanged. Clicking a point within a linked line activates the native anchor. Neither result requires an invented browser defect.
Sample the linked fragments
The next helper clips each fragment to the viewport, discards empty intersections and samples a center. It accepts that point only when the browser reports the link or one of its descendants there. This keeps geometry and ownership in the same viewport coordinate system.
function linkedFragmentPoint(link) {
for (const rect of link.getClientRects()) {
const left = Math.max(0, rect.left);
const right = Math.min(innerWidth, rect.right);
const top = Math.max(0, rect.top);
const bottom = Math.min(innerHeight, rect.bottom);
if (right <= left || bottom <= top) continue;
const point = {
x: (left + right) / 2,
y: (top + bottom) / 2,
};
const hit = document.elementFromPoint(point.x, point.y);
if (hit === link || link.contains(hit)) return point;
}
throw new Error("No sampled fragment center belongs to the link");
}
const point = linkedFragmentPoint(
document.querySelector("#demo-link")
);This is a small same-document HTML diagnostic. Sampling one center per fragment cannot prove that every part is visible or clickable. An overlay may cover only some points, and the layout may change between measurement and activation. Rotated shapes, embedded documents and more elaborate controls deserve their own tests.
Give a navigation item a continuous box
For a table of contents, a block-shaped link may better match the intended interaction than separate inline fragments. MDN documents display as controlling whether an element participates as a block or inline box. The following CSS applies that choice to our navigation link, with padding and room for text to wrap. [4]
.demo-toc a {
display: block;
box-sizing: border-box;
max-width: 100%;
min-height: 44px;
padding: 8px 12px;
overflow-wrap: anywhere;
}The result is still an anchor with its original destination. In this fixture its enclosing center now belongs to the link, including space between wrapped text lines. The 44-pixel minimum is a design choice for the example, rather than a claim that one dimension proves accessibility conformance.
Observe navigation through both input paths
Playwright documents mouse coordinates in main-frame CSS pixels measured from the viewport's top-left corner. Its keyboard API supports pressing keys such as Enter. Those APIs let the final example check the effect of pointer and keyboard activation, rather than merely dispatching a scripted click event on the node. [5] [6]
The example assumes a Playwright page contains Example 1 with Example 4 applied. It changes viewport width and the body's font size, clears the fragment between observations, and verifies the actual destination after each activation. Keyboard focus is explicit here; the accompanying fixture checks Tab navigation separately.
async function resetFragment(page) {
await page.evaluate(() => {
history.replaceState(null, "", location.href.split("#")[0]);
scrollTo(0, 0);
});
}
const results = [];
for (const width of [320, 640, 1024]) {
await page.setViewportSize({width, height: 900});
for (const fontSize of [16, 32]) {
await page.locator("body").evaluate((node, size) => {
node.style.fontSize = size + "px";
}, fontSize);
await resetFragment(page);
const point = await page.locator("#demo-link").evaluate(link => {
const box = link.getBoundingClientRect();
const p = {x: box.left + box.width / 2,
y: box.top + box.height / 2};
const hit = document.elementFromPoint(p.x, p.y);
if (!(hit === link || link.contains(hit))) {
throw new Error("The link does not own its center");
}
return p;
});
await page.mouse.click(point.x, point.y);
if (await page.evaluate(() => location.hash) !== "#chapter") {
throw new Error("Pointer activation failed");
}
await resetFragment(page);
await page.locator("#demo-link").focus();
await page.keyboard.press("Enter");
if (await page.evaluate(() => location.hash) !== "#chapter") {
throw new Error("Keyboard activation failed");
}
results.push({width, fontSize, pointer: true, keyboard: true});
}
}All five examples ran in headless Chromium 151.0.7922.34. Six width/text-size combinations passed both activation checks. Nine additional checks covered the original gap, fragment selection, overlays, hidden and off-screen links, pointer-disabled content, Tab/Enter activation and a deliberately reintroduced gap. Every fixture request was intercepted, with no external fixture traffic.
Changing the font from 16 to 32 pixels models enlarged text in this example. It is not native browser zoom, a physical touchscreen result or a whole-page accessibility assessment. The test also observes one settled layout at a time; an animated or frequently changing component needs checks appropriate to that behavior.
Our earlier layout note separates document width from collisions between controls. This example examines a different boundary: one element's enclosing rectangle, its individual fragments and the point that actually receives input. Keep those observations distinct, then verify the action the person intended to take. [7]
Sources + further reading
Source dates describe the original material. Publication above is the date this Zyel article went live.
- Element: getClientRectsMDN Web Docs · Checked Dec 2, 2026
- Element: getBoundingClientRectMDN Web Docs · Checked Dec 2, 2026
- Document: elementFromPointMDN Web Docs · Checked Dec 2, 2026
- CSS display: block and inline boxesMDN Web Docs · Checked Dec 2, 2026
- Playwright Mouse APIPlaywright · Checked Dec 2, 2026
- Playwright Keyboard APIPlaywright · Checked Dec 2, 2026
- A page can fit while its controls collideZyel · Checked Dec 2, 2026
Reader discussion
What would you ask next?
Questions, useful corrections and thoughtful disagreement are welcome. Comments are reviewed before they appear.
No reader comments yet.