0

Possible Duplicate:
Horizontally and vertically center a pre tag without the use of tables?

How do I horizontally and vertically center text without specifying the width?

Now I have:

<div class="center">
<p id="logo"><span>Coming soon!</span></p>
</div>

and the CSS is:

span {
    color:#ff0000;
    font-size: 14px;
    font-weight:normal;
    font-family:sans-serif;
    border-bottom-color: currentColor;
    border-bottom-style: dotted;
    border-bottom-width: 1px;
    line-height: 1.1;
}
.center {
    width:150px;
    height:100px;
    position:absolute;
    left:50%;
    top:50%;
    margin-left:-100px;
    margin-top:-50px;
}

Because the text would be different widths, I need another solution.

Community
  • 1
  • 1
Natio Li
  • 41
  • 1
  • 7

1 Answers1

1

Give your center class the following CSS:

text-align:center;
line-height: 100px;

Note that this will only work for a single line of text. See an example at jsFiddle.

j08691
  • 204,283
  • 31
  • 260
  • 272