CSSTemplates.NET
Cascading Style Sheet TemplatesPremium CSS Templates
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
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>
.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>
.cimage{
padding-left: 50%
}
img{
margin-left: -50px; /* half of the image width */
}

