CSS vertical text centering. Why is this so incompatible?

Let's start with the answer: Is it possible to vertically align text in a div?

There is a CSS property, which is vertical-alignalso called another, that line-height I would expect if I placed the text inside the element (div, span, p) and this element set the property vertical-align: middle, the height of the rendered text will be calculated, the height of the displayed container element and the text will be centered vertically inside a container element.

But according to the answer, it seems like this is not the case:

which is related to the row height. If you add height to an element, where exactly is the text inside it? That is, if you have a block of text, font size: 10 pixels (theoretical height: 10 pixels) inside a container that is 60 pixels, where exactly will the text be in the end? Most of course, at the top of the container, because the text can only position where the text flows, inside the height: 10px space

I do not understand this. The line height should affect the distance between the two lines. It should work as a kind of margin-top applied to each letter of the text. Intuitively, I would expect that vertical alignment is stronger than margin.

How should I understand why the vertical alignment behavior is not the vertical alignment of elements as expected? Why is CSS creators making this choice?

    #column-content {
      display: inline-block;
      border: 1px solid red;
      position: relative;
    }
    #column-content strong {
      color: #592102;
      font-size: 18px;
    }
    img {
      margin-top: -7px;
      vertical-align: middle;
    }
    span {
      display: inline-block;
      vertical-align: middle
    }
<div id="column-content">

  <img src="http://i.imgur.com/WxW4B.png">
  <span><strong>1234</strong>
    yet another text content that should be centered vertically</span>
</div>
Hide result
+4
1

All Articles