Skip to: Site menu | Main content

Premium CSS Templates

Web Designers Directory Visit our new Web Designers Directory if you are looking for active and reliable Web or CSS Designers to create your CSS or professional templates.

CSS Templates on the Net

More than 3000 free css templates

Centering Text

To align text in the center of a page, simply utilize the property, text-align as follows:

In CSS file:

h1, h2, p{
text-align: center;
}

All the text in the h1, h2 and p will be positioned at the center of the container.

Centering Table

To center a table, place it under a div container as follows:

In HTML file:

<div class="center">
<table>
<tr>
<td> First cell </td>
</tr>
</table>
</div>

In CSS file:

.center {
text-align: center;
}
.center table{
margin: 0 auto;
text-align: left;
}

Centering Images

To center an image, place it in a div element as follows:

In HTML file:

<div class="cimage">
<img src="example.jpg" width="100px" height="50px" alt="An centering image example" />
</div>

In CSS file:

.cimage{
padding-left: 50%
}
img{
margin-left: -50px; /* half of the image width */
}

[ Back to CSS Quick Guide ]

Custom Secure Hosting

Affordable and Reliable Web Hosting

Advertise with us