white-space-collapse-000

White space collapse

WeasyPrint

This browser

Flags
script
Assertion
Every tab is converted to a space. Any space immediately following another collapsible space is collapsed to have zero advance width.

Source

 1 <!DOCTYPE html>
 2 <html lang="en"><head>
 3 <meta charset="utf-8">
 4 <title>White space collapse</title>
 5 <link href="mailto:ishida@w3.org" rel="author" title="Richard Ishida">
 6 <link href="https://drafts.csswg.org/css-text-3/#line-break-transform" rel="help">
 7 <meta content="Every tab is converted to a space. Any space immediately following another collapsible space is collapsed to have zero advance width." name="assert">
 8 <style type="text/css">
 9 .test span { font-size: 24px; font-family: sans-serif; background-color: #2AA5F7; color: white; }
10 .ref span { font-size: 24px; font-family: sans-serif; background-color: #270CEF; color: white; }
11 </style>
12 <script src="/resources/testharness.js"></script>
13 <script src="/resources/testharnessreport.js"></script>
14 </head>
15 <body>
16 <div id="log"></div>
17 <div class="test" id="test"><span>hello   	       there</span></div>
18 <div class="ref" id="ref"><span>hello there</span></div>
19 <div class="test" id="testW"><span>缔造真正全球通行       	   的万维网</span></div>
20 <div class="ref" id="refW"><span>缔造真正全球通行 的万维网</span></div>
21 <div class="test" id="testF"><span>FULL   	        WIDTH</span></div>
22 <div class="ref" id="refF"><span>FULL  WIDTH</span></div>
23 <div class="test" id="testH"><span>ハン   	         カク</span></div>
24 <div class="ref" id="refH"><span>ハン   カク</span></div>
25 <script>
26 test(function() {
27 assert_equals(document.getElementById('test').firstChild.offsetWidth, document.getElementById('ref').firstChild.offsetWidth);
28 }, "spaces removed");
29 test(function() {
30 assert_equals(document.getElementById('testW').firstChild.offsetWidth, document.getElementById('refW').firstChild.offsetWidth);
31 }, "spaces removed between Wide characters");
32 test(function() {
33 assert_equals(document.getElementById('testF').firstChild.offsetWidth, document.getElementById('refF').firstChild.offsetWidth);
34 }, "spaces removed between Fullwidth characters");
35 test(function() {
36 assert_equals(document.getElementById('testH').firstChild.offsetWidth, document.getElementById('refH').firstChild.offsetWidth);
37 }, "spaces removed between Halfwidth characters");
38 </script>
39 <!-- Notes:
40 The assertion will fail if space is produced for any line in the test paragraph.
41 -->
42 
43 
44 
45 
46 </body></html>