Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /css/css-writing-modes/orthogonal-block-in-inline-inline-size-002.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<meta charset="utf-8">
<title>CSS Test: an orthogonal block level box on a line contributes its margins along the line to its container's inline size</title>
<meta name="assert" content="A block level box on a line whose writing mode is orthogonal to the line's contributes the margins on its sides along the line's inline axis to its container's inline size, the same as it does as a block sibling.">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<link rel="stylesheet" href="/fonts/ahem.css">
<style>
.container {
width: max-content;
font: 10px/1 Ahem;
}
.orthogonal {
writing-mode: vertical-lr;
width: 40px;
margin: 1px 2px 3px 4px;
}
</style>
<!-- The box has content of its own. Its top and bottom margins (1px and 3px) add up to less than its left and
right ones (4px and 2px), so taking one pair for the other makes the container narrower.
nested: the block level box is an inline box's only child, so it sits on a line.
sibling: it is a plain block child of the container. -->
<div class="container" id="nested"><span><div class="orthogonal">x</div></span></div>
<div class="container" id="sibling"><div class="orthogonal">x</div></div>
<script>
for (const id of ["nested", "sibling"]) {
test(() => {
assert_equals(document.getElementById(id).offsetWidth, 46, "the box's 40px width plus its 4px left and 2px right margins");
}, `An orthogonal block level box contributes its left and right margins to its container's inline size (${id})`);
}
</script>