Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /css/css-sizing/svg-intrinsic-size-009.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<meta charset="utf-8">
<title>Intrinsic size contribution of a block-level SVG in a max-content sized container</title>
<link rel="author" title="Emilio Cobos Álvarez" href="mailto:emilio@crisal.io">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/check-layout-th.js"></script>
<style>
.block {
width: max-content;
border: 2px solid black;
}
svg {
display: block;
height: auto;
background: cyan;
}
</style>
<body onload="checkLayout('.block, svg')">
No intrinsic attributes:
<div class="block" data-expected-client-width="300">
<svg data-expected-client-width="300" data-expected-client-height="150"></svg>
</div>
viewBox and height:
<div class="block" data-expected-client-width="100">
<svg height="100" viewBox="0 0 100 100"
data-expected-client-width="100" data-expected-client-height="100"></svg>
</div>
viewBox and height (non-square):
<div class="block" data-expected-client-width="160">
<svg height="40" viewBox="0 0 4 1"
data-expected-client-width="160" data-expected-client-height="40"></svg>
</div>
viewBox and width:
<div class="block" data-expected-client-width="40">
<svg width="40" viewBox="0 0 4 1"
data-expected-client-width="40" data-expected-client-height="10"></svg>
</div>
viewBox, width, height:
<div class="block" data-expected-client-width="40">
<svg width="40" height="40" viewBox="0 0 4 1"
data-expected-client-width="40" data-expected-client-height="40"></svg>
</div>
Just viewBox:
<div class="block" data-expected-client-width="0">
<svg viewBox="0 0 4 1"
data-expected-client-width="0" data-expected-client-height="0"></svg>
</div>
</body>