Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /css/css-text/wrap-inside/wrap-inside-avoid-dynamic.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<meta charset="utf-8">
<title>wrap-inside: avoid triggers relayout when set dynamically</title>
<link rel="match" href="wrap-inside-avoid-dynamic-ref.html">
<meta name="assert" content="Changing wrap-inside to 'avoid' on an already-laid-out inline box re-runs line layout: the box that used to break inside is now kept together by breaking before it.">
<link rel="stylesheet" href="/fonts/ahem.css">
<style>
div { width: 110px; font: 20px/20px Ahem; color: green; }
</style>
<!--
Initially (wrap-inside: auto) "XX YY" (100px) fits within 110px, so the line breaks
inside the box as "XX YY" / "ZZ". After setting 'wrap-inside: avoid' the box must be
kept together, re-breaking before it as "XX" / "YY ZZ" - which requires a relayout.
-->
<div>XX <span id="target">YY ZZ</span></div>
<script>
// Force layout in the initial (auto) state so the change below must trigger a relayout.
document.body.offsetTop;
document.getElementById("target").style.wrapInside = "avoid";
</script>