how to center text vertically in html using css only

Tags: html,css,text,center

Problem :

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.

<div>Ops, the webpage is currently not available</div>

Note that the size of the html can be variable.

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

Is it possible?

Solution :

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

    CSS Howto..

    How to programmatically apply CSS definitions to the whole page?

    how to select last element in the page?

    How can I print the selected item from bootstrap drop down using jquery or javascript in php

    How to store “state” in CSS only?

    How to create an overlay to be used under a pop up

    How to assign inner shadow to inputs in CSS

    Using CSS to show/hide content. How do I make hide the default

    how do I select second submit button to imply other color

    How to extend the length of a page through CSS?

    How to make arrows on both sides of a box using css [duplicate]

    Show and Hide option for DIV(needs modification)

    Flask - How to use CSS when i'm using Response(stream_template) with generator

    How to make CSS fade out but the HTML to collapse

    How to put a border on a triangle shape using css?

    How can I make this container and table responsive for mobile and ipad size?

    How to prevent selecting text on double click?

    How to implement a navbar with HTML / CSS

    How do you make an input element fill parent?

    how to reference background image urls in css through config entrys

    Using html5 canvas as a background, how to position a youtube embed on top of it using css to be resolution independent?

    How to preserve margins and expand a div to fit its contents size?

    How to create cascading menus in rails?

    how to show limited text in css [closed]

    How to change the background color(on hover) and css(height/width) of a select option?

    How to show a small image to the right of a div with CSS?

    how to remove selected option background color in IE browser through css?

    How to highlight one image over other using jquery css? [duplicate]

    CSS and HTML: How to create an Expanding DIV On Click?

    How to make a multi category filter with JQuery, HTML and CSS

    How to set CSS attributes relative to a parent node?