I have an alignment problem in html/css. I simplified my problem to this:
<!DOCTYPE html>
<html>
<head>
<title>Test</title>
<style>
span { display: inline-block; height: 50px; }
span.text { background-color: Yellow;}
span.left, span.right { background-color: Red; width: 20px;}
</style>
</head>
<body>
<span class="left">x</span>
<span class="text">Text comes here</span>
<span class="right">x</span>
</body>
</html>
The output in the browser is as expected:

However, span.left and span.right should not contain any content. They are there for layout purposes only. But when I remove the content (“x”) of both spans like this:
<span class="left"></span>
<span class="text">Text comes here</span>
<span class="right"></span>
The output changes to this:

Why is it doing this? What can I do to solve this?
Vertical align is problematic, since it is set to the default baseline. Just change it to top: