Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /css/css-anchor-position/anchor-position-principal-box.html - WPT Dashboard Interop Dashboard
<!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>