Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to center text vertically in HTML using CSS only

I have a very simple HTML. Due to some limitations, I cannot modify the HTML content. I want to center the text vertically only using CSS.

<html>
    <head>...</head>

    <body>
        <div>Oops, the webpage is currently not available.</div>
    </body>
</html>

Note that the size of the HTML can be variable.

In addition, if the text cannot be displayed in one line, it should be broken into multiple lines.

Is it possible?

like image 212
stanleyxu2005 Avatar asked Feb 27 '23 22:02

stanleyxu2005


1 Answers

I think vertical-align only works for content which is in a table. For your simple page you could put the content in a table instead of a div to avoid this problem.

There are some workarounds, see http://phrogz.net/css/vertical-align/index.html

like image 160
Matschie Avatar answered Mar 05 '23 23:03

Matschie