Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /css/css-tables/html-to-css-mapping-1.html - WPT Dashboard Interop Dashboard
<!doctype html>
<script src='/resources/testharness.js'></script>
<script src='/resources/testharnessreport.js'></script>
<link rel='stylesheet' href='./support/base.css' />
<main>
<h1>HTML-2-CSS Mapping</h1>
<p>Checks that browsers implement properly the html2css stylesheet (rules without attributes)</p>
<hr/>
<p>You should see a 5 2px blue square here, separated by 2px each:</p>
<p>Because of the lack of the table element, border-spacing is 0; padding on each td should be 1px on each side. 1px*2*5=10px.</p>
<div><table><tbody style="background: blue; height: 2px"><tr><td></td><td></td><td></td><td></td><td></tr></tbody></table></div>
<hr/>
<p>You should see a 10px blue square here:</p>
<p>Because of the lack of the table element, border-spacing is 0; padding on each td should be 1px on each side. 1px*2*5=10px.</p>
<div><table class="to-remove"><tbody style="background: blue; height: 10px"><tr><td></td><td></td><td></td><td></td><td></tr></tbody></table></div>
<hr/>
<p>You should see a 12px blue square here:</p>
<p>The table has the background; x-td elements have no padding, only the border-spacing remains. 6*2px=12px.</p>
<div><table style="height: 12px; background: blue;" class="no-td"><tbody><tr><td></td><td></td><td></td><td></td><td></tr></tbody></table></div>
<hr/>
<p>You shouldn't see anything here:</p>
<p>The table has the background but is empty; it does not apply border-spacing in this case.</p>
<div><table style="height: 2px; background: red"></table></div>
<script>void function() { var table; while(table = document.querySelector('.to-remove')) table.parentNode.replaceChild(table.firstChild,table) }();</script>
<script>void function() { var td; while(td = document.querySelector('table.no-td td')) td.parentNode.replaceChild(document.createElement('x-td'),td) }();</script>
</main>
<script>
var i = 1;
generate_tests(assert_equals, [
[
"HTML -> CSS Mapping is applied correctly on proper table markup (border-spacing, padding)",
document.querySelector("main > div:nth-of-type("+(i++)+") table").offsetWidth,
22
],
[
"HTML -> CSS Mapping is applied correctly on improper table markup (no table => no border-spacing, but padding)",
document.querySelector("main > div:nth-of-type("+(i++)+") tbody").offsetWidth,
10
],
[
"HTML -> CSS Mapping is applied correctly on improper table markup (no td => border-spacing, but no padding)",
document.querySelector("main > div:nth-of-type("+(i++)+") table").offsetWidth,
12
],
[
"HTML -> CSS Mapping is applied correctly on empty table markup (no content => no border-spacing, no padding)",
document.querySelector("main > div:nth-of-type("+(i++)+") table").offsetWidth,
0
],
])
</script>