Source code

Revision control

Copy as Markdown

Other Tools

Test Info:

<!DOCTYPE html>
<title>anchor-name only applies to elements which generate a principal box</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<style>
body { margin-top: 0; }
#outer {
anchor-name: --anchor;
display: contents;
}
#inner {
anchor-name: --anchor;
}
#filler {
height: 100px;
}
#anchored {
position: absolute;
top: anchor(--anchor top);
}
</style>
<div id="outer">
<div id="filler"></div>
<div id="inner"></div>
</div>
<div id="anchored"></div>
<script>
test(() => {
assert_equals(anchored.offsetTop, 100, "#anchored is positioned against #inner");
}, "anchor-name should only apply to elements which generate a principal box");
</script>