Feature table design with CSS3

I love shadows, rounded corners, gradients and all the CSS3 features. That’s why, there are some days when I find myself designing in CSS3 more than in Photoshop.

The idea of building a features table just by using CSS3 came to me a while ago and I decided to share it with you in this article.


You can check a preview of the result below, or view the demo and download the source files from the buttons below the image.

View DemoDownload Files

The HTML markup

Below you can find the abbreviated HTML:

<table class="features-table">
	<thead>
		<tr>
			<td></td>
			<td>Standard</td>
			<td>Professional</td>
			<td>Enterprise</td>
		</tr>
	</thead>
	<tfoot>
		<tr>
			<td></td>
			<td>$99</td>
			<td>$199</td>
			<td>$399</td>
		</tr>
	</tfoot>
	<tbody>
		<tr>
			<td>Custom domain</td>
			<td><img src="check.png" width="16" height="16" alt="check"></td>
			<td><img src="check.png" width="16" height="16" alt="check"></td>
			<td><img src="check.png" width="16" height="16" alt="check"></td>
		</tr>
		<tr>
			<td>Advanced control</td>
			<td><img src="check.png" width="16" height="16" alt="check"></td>
			<td><img src="check.png" width="16" height="16" alt="check"></td>
			<td><img src="check.png" width="16" height="16" alt="check"></td>
		</tr>
		<tr>
			<td>Unlimited support</td>
			<td><img src="cross.png" width="16" height="16" alt="cross"></td>
			<td><img src="check.png" width="16" height="16" alt="check"></td>
			<td><img src="check.png" width="16" height="16" alt="check"></td>
		</tr>
		<tr>
			<td>User registration</td>
			<td><img src="cross.png" width="16" height="16" alt="cross"></td>
			<td><img src="cross.png" width="16" height="16" alt="cross"></td>
			<td><img src="check.png" width="16" height="16" alt="check"></td>
		</tr>
	</tbody>
</table>

Note that the markup it’s quite minimal, excepting the check and cross icons needed to point available and unavailable features.

To better target the cells I used elements like thead, tfoot or tbody. You’ll see below that’s easier now to select cells, without adding different CSS classes for rows and/or cells.

The CSS:

For this example, I used CSS3 selectors (or pseudo-selectors) as :nth-child(n) or :first-child. Of course IE6 to IE8 won’t render the table as modern browsers like Firefox, Chrome, Safari or Opera.

IE9 and Opera instead behaves nice, excepting the lack of support for CSS gradients.

.features-table
{
  width: 100%;
  margin: 0 auto;
  border-collapse: separate;
  border-spacing: 0;
  text-shadow: 0 1px 0 #fff;
  color: #2a2a2a;
  background: #fafafa;
  background-image: -moz-linear-gradient(top, #fff, #eaeaea, #fff); /* Firefox 3.6 */
  background-image: -webkit-gradient(linear,center bottom,center top,from(#fff),color-stop(0.5, #eaeaea),to(#fff));
}

.features-table td
{
  height: 50px;
  line-height: 50px;
  padding: 0 20px;
  border-bottom: 1px solid #cdcdcd;
  box-shadow: 0 1px 0 white;
  -moz-box-shadow: 0 1px 0 white;
  -webkit-box-shadow: 0 1px 0 white;
  white-space: nowrap;
  text-align: center;
}

/*Body*/
.features-table tbody td
{
  text-align: center;
  font: normal 12px Verdana, Arial, Helvetica;
  width: 150px;
}

.features-table tbody td:first-child
{
  width: auto;
  text-align: left;
}

.features-table td:nth-child(2), .features-table td:nth-child(3)
{
  background: #efefef;
  background: rgba(144,144,144,0.15);
  border-right: 1px solid white;
}

.features-table td:nth-child(4)
{
  background: #e7f3d4;
  background: rgba(184,243,85,0.3);
}

/*Header*/
.features-table thead td
{
  font: bold 1.3em 'trebuchet MS', 'Lucida Sans', Arial;
  -moz-border-radius-topright: 10px;
  -moz-border-radius-topleft: 10px;
  border-top-right-radius: 10px;
  border-top-left-radius: 10px;
  border-top: 1px solid #eaeaea;
}

.features-table thead td:first-child
{
  border-top: none;
}

/*Footer*/
.features-table tfoot td
{
  font: bold 1.4em Georgia;
  -moz-border-radius-bottomright: 10px;
  -moz-border-radius-bottomleft: 10px;
  border-bottom-right-radius: 10px;
  border-bottom-left-radius: 10px;
  border-bottom: 1px solid #dadada;
}

.features-table tfoot td:first-child
{
  border-bottom: none;
}

View DemoDownload Files

IE Graceful Degradation

Now if you want this table to degrade gracefully for IE you must add different classes for cells and skip the pseudo-selectors part. The main disadvantage is the use of extra markup.

I also made an example without pseudo-selectors and bellow you can see a demo or download files.

View 2nd example DemoDownload 2nd example Files

Hope you enjoyed this article and looking forward for your opinions regarding it!

Related content

Written by Red

Catalin Rosu, a.k.a Red, is a professional web designer and developer who loves to be creative and enjoys CSS techniques. Stay tuned for latest updates, subscribe to RSS and follow him on Twitter.

13 Responses to “Feature table design with CSS3”

  1. Robson Sobral says:

    Hello, dude! Pretty work, but I have one question. Why not use the tag TH, instead of TD B?

  2. Rocco Tarasi says:

    Nice article. I’ve indexed it so that readers can earn 3 credits for learning this technique (and I’ll probably use it on our future feature tables).
    http://braincredits.com/Lesson/11111.
    BrainCredits is an online Transcript for readers to earn credit for informal learning like this.

  3. Giuseppe says:

    I discovered this site recently and I am favorably impressed. Great job

  4. Mandy says:

    Great Article. Thanks for the coding, I am using it in my website. Thanks for sharing.

  5. Alyssa says:

    Thanks for posting, really nice table, saved me hours of mucking about!

  6. Javed says:

    Really you did a master job.

  7. James Bete says:

    Hi Red,

    Thank you so much for sharing this code. Its very helpful to me right now that I am designing a pricing comparison page for my new website.

    Excellent job!

    James

  8. norleb says:

    Hi Red,

    Nice tutorial!

    BTW, I would like to change the color of the last background from #e7f3d4; to a darker shade or other color like #cfe592;

    However, I’m not getting the same effect of having a light border on it. Something involves with the second background definition or rgba thing next to it?

    Thanks.

Leave a Reply