File: inline-block-baseline-015.html

package info (click to toggle)
firefox 144.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 4,637,504 kB
  • sloc: cpp: 7,576,692; javascript: 6,430,831; ansic: 3,748,119; python: 1,398,978; xml: 628,810; asm: 438,679; java: 186,194; sh: 63,212; makefile: 19,159; objc: 13,086; perl: 12,986; yacc: 4,583; cs: 3,846; pascal: 3,448; lex: 1,720; ruby: 1,003; exp: 762; php: 436; lisp: 258; awk: 247; sql: 66; sed: 53; csh: 10
file content (55 lines) | stat: -rw-r--r-- 2,151 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<!DOCTYPE html>
<title>Vertical-align: baseline of inline-block with phantom line box</title>
<link rel="author" title="Oriol Brufau" href="obrufau@igalia.com">
<link rel="help" href="https://drafts.csswg.org/css2/#leading">
<link rel="help" href="https://drafts.csswg.org/css2/#inline-formatting">
<link rel="match" href="../../reference/ref-filled-green-200px-square.html">
<meta name="assert" content="
  From https://drafts.csswg.org/css2/#leading
  > The baseline of an inline-block is the baseline of its last line box in the normal flow,
  > unless it has either no in-flow line boxes or if its overflow property has a computed
  > value other than visible, in which case the baseline is the bottom margin edge.

  Here we have 2 inline-blocks. The 1st one is completely empty, so it baseline is its
  bottom margin edge. The 2nd one has an empty span followed by a block.

  The span would typically be placed in a line box. However, it's a phantom line box.
  From https://drafts.csswg.org/css2/#inline-formatting
  > Line boxes that contain no text, no preserved white space, no inline elements with
  > non-zero margins, padding, or borders, and no other in-flow content (such as images,
  > inline blocks or inline tables), and do not end with a preserved newline must be
  > treated as zero-height line boxes for the purposes of determining the positions of
  > any elements inside of them, and must be treated as not existing for any other purpose.

  So for the purpose of finding the baseline of the 2nd inline-block we ignore the phantom
  line box, and thus the baseline is also the bottom margin edge.

  Therefore, the inline-blocks should have their bottom margin edges aligned.
">

<style>
.wrapper {
  width: 200px;
  background: red;
  line-height: 0;
  font-size: 0;
}
.green {
  width: 100px;
  height: 200px;
  background: green;
}
.inline-block {
  display: inline-block;
}
</style>

<p>Test passes if there is a filled green square and <strong>no red</strong>.</p>

<div class="wrapper">
  <div class="inline-block green"></div>
  <div class="inline-block">
    <span></span>
    <div class="green"></div>
  </div>
</div>