How to align a div inside td element using CSS class

MonsterMMORPG picture MonsterMMORPG · Aug 15, 2011 · Viewed 104.4k times · Source

It is working with this way

<td align="center">

But I want to use CSS class.

I defined class like this way but no luck

td
{
    vertical-align: middle;
    text-align: center;
    margin-left: auto;
    margin-right: auto;
    align: center;
}

Vertical align is working and text align is working for text. But it does not align div inside td with this way. I want to align div inside td.

Answer

Luuk picture Luuk · Aug 15, 2011
div { margin: auto; }

This will center your div.

Div by itself is a blockelement. Therefor you need to define the style to the div how to behave.