padding-em-inherit-001.xht (2705B)
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 2 3 <html xmlns="http://www.w3.org/1999/xhtml"> 4 5 <head> 6 7 <title>CSS Test: inherit applied on padding set with em</title> 8 9 <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" /> 10 <link rel="help" title="8.4 Padding properties" href="http://www.w3.org/TR/CSS21/box.html#padding-properties" /> 11 <link rel="help" title="4.3.2 Length" href="http://www.w3.org/TR/CSS21/syndata.html#length-units" /> 12 <link rel="help" title="6.2.1 The 'inherit' value" href="http://www.w3.org/TR/CSS21/cascade.html#value-def-inherit" /> 13 <link rel="help" href="http://www.w3.org/TR/css-cascade-3/#inherit" /> 14 <link rel="help" href="http://www.w3.org/TR/css-cascade-4/#inherit" /> 15 <link rel="match" href="padding-em-inherit-001-ref.xht" /> 16 17 <meta content="The 'em' unit is equal to the computed value of the 'font-size' property of the element on which it is used. When inherit keyword is used, the property takes the same computed value - a length value in this testcase - as the property for the element's parent." name="assert" /> 18 <meta content="image" name="flags" /> 19 20 <style type="text/css"><![CDATA[ 21 body {margin: 8px;} 22 23 p 24 { 25 font: 1em/1.25 serif; 26 margin: 1em 0em; 27 } 28 29 div#grand-parent 30 { 31 font-size: 32px; 32 width: 400px; 33 } 34 35 div#parent 36 { 37 background-color: green; 38 font-size: 24px; 39 padding: 2em 3em 1em 4em; /* 48px 72px 24px 96px */ 40 } 41 42 div#child 43 { 44 font-size: 40px; 45 padding: inherit; 46 /* 47 What is inherited is a computed length value: 48 so it is 48px 72px 24px 96px and not 80px 120px 40px 160px 49 */ 50 } 51 52 div#abs-pos-overlapping-green 53 { 54 left: 200px; 55 /* 56 8px (body's margin-left) 57 + 58 96px (#parent's padding-left) 59 + 60 96px (#child's padding-left) 61 ================== 62 200px 63 */ 64 position: absolute; 65 top: 168px; 66 } 67 68 /* 69 max(8px, 16px) (margin collapsing between body's margin-top and p's margin-top) 70 + 71 20px (first line) 72 + 73 20px (second line) 74 + 75 16px (p's margin-bottom) 76 + 77 48px (#parent's padding-top) 78 + 79 48px (#child's padding-top) 80 ================== 81 168px 82 */ 83 ]]></style> 84 85 </head> 86 87 <body> 88 89 <p>Test passes if there is a filled<br /> 90 green rectangle and no red.</p> 91 92 <div id="grand-parent"> 93 <div id="parent"> 94 <div id="child"><img src="support/100x100-red.png" alt="Image download support must be enabled" /></div> 95 </div> 96 </div> 97 98 <div id="abs-pos-overlapping-green"><img src="support/swatch-green.png" width="100" height="100" alt="Image download support must be enabled" /></div> 99 100 </body> 101 </html>