Answer to Original Question:
When you specify vertical-align: top
The top of the element is aligned with the top of the tallest element on the line
. In your case, the div
siblings a and b are on the line
within the parent div container
. So, the logical place to give the vertical-alignment is at the div sibling
level.
Answer to your comment question:
I don't understand why the blue box moves up when I apply vertical-align-top to the green box.
If the vertical-align: top
property is applied to the tallest element on the line, then the sibling which in your case is div a
would align to the tallest.
If you want to explore more take a look at the JSFiddle Example.
Look how a
,b
,c
,d
and e
are aligned when I set the vertical-align: top
property on the c div
which is the tallest one. In this case, within siblings divs a, b, d and e
, d
is the tallest so it gets aligned to the tallest element i.e. c
but a
,b
and e
are aligned to the horizontal baseline of d
who is the next tallest.