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 get Mouse Out effect in CSS

    How to centre text as CSS content attribute vertically and horizontally?

    when click on button then show message

    How to apply css styles in embed widget

    How Do I Set the condition for a user to have to fill in a Textfield

    How do I move this label inside my textarea?

    How can I get drop-down functionality working with CSS?

    How to Add CSS Reference to .NET SyndicationFeed?

    How to add a new CSS class to a Link Badge if the value is 0?

    How do I correct this error?

    How to align div elements while using css tables

    CSS - How do I center a loading icon on a page that contains an iframe?

    How can we customize vs2010 css editor template?

    How to make rollover images in CSS using multiple image backgrounds and :hover pseudo

    How to I center my submit button in CSS?

    How to overwrite styling in Twitter Bootstrap

    Does anybody know how I can adjust this CSS to achieve the desired hyperlink effect I'd like?

    How to make an image not overlap navigation bar in CSS/HTML [closed]

    IE7: CSS & jQuery: dragging up, dragged item is on top, dragging down: dragged item is below. How do I get both to be on top?

    Show text underneath image while hovering without disrupting other elements

    How to make a CSS rule act differently inside another div tag?

    How to prevent HTML code in a literal inside a DIV from affecting outer page styles

    Overlay image to show like panorama [closed]

    How can I prevent divs animated using CSS keyframes from colliding

    How can I explain to a programmer that CSS positioning has many benefits over table based layouts?

    How to reference JSF image resource as CSS background image url

    How to select nested UL element without class in JavaScript

    How to center this stuff inside a link using CSS?

    How to include a css class that is an image on codeigniter form submit?

    Pure JavaScript - how to add class to a class? Or change style in class