CSSTemplates.NET
Cascading Style Sheet TemplatesFree CSS Templates
Download the top 10 CSS templates here that are carefully selected by
us. You will get to receive other freebies such as Icons, headers and useful tools. Made possible by CSSTemplates.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 */
}

