CSS
HTML
JavaScript
jQuery
PHP
SQL
WordPress
CSS Tutorials

Overview

HTML tables can be styled to a point using tag attributes like border, cell-padding, cell-spacing, and width/height.

				
					<table border="1" cellpadding="5" cellspacing="5" width="300">
    <tr>
		<th></th>
		<th></th>
	</tr>
	<tr>
		<td></td>
		<td></td>
	</tr>
</table>
				
			

However this is somewhat limited, and CSS can be used to make your tables look exactly as you intend.

Plus, the styles will apply to all tables site wide, removing the need to style each table individually from within the table tag.

Using CSS

Setting the Width

				
					table {
    width: 100%;
}
				
			

Styling and Collapsing the Border

By default a table will have a border around it and each cell will have a border around it, and there is space between these borders creating a double-border effect. By using the border-collapse property, these borders are merged into one making them more pleasing to the eye. And to add to the look, we can set the border color, style, and size.

				
					table, th, td {
    border: red solid thin;
    border-collapse: collapse;
}
				
			

Adjusting Text and Padding

				
					th, td {
    color: red;
    font-size: 12px;
    font-weight: bold;
    padding: 10px;
    text-align: left;
}
				
			

Table-Specific Properties

We’d like to acknowledge that we learned a great deal of our coding from W3Schools and TutorialsPoint, borrowing heavily from their teaching process and excellent code examples. We highly recommend both sites to deepen your experience, and further your coding journey. We’re just hitting the basics here at 1SMARTchicken.

CSS
HTML
JavaScript
jQuery
PHP
SQL
WordPress

Why 1SMARTchicken?

This site was built and is maintained to benefit my autistic son.
See More →

My Son's Name is Johnny

He was diagnosed as autistic quite late, at age four...
His story

Buy Me a Coffee

Thanks for your support!

Feedback

If you see an error on the page or the code itself is incorrect or incomplete, or just plain wrong, please let us know. We’re always learning. NOTE: we do not sell your information and will not send you spam emails.