Back to Writing

HTML Table Style Generator

A tool for quickly generating and styling HTML tables with CSS.

Eli Geske 22 min read
css generator html table data-grid table-styler table-generator web-tools

I have been working on a few projects lately that require a lot of tables. I have always found it to be a bit of a pain to style tables. I decided to create a tool that would allow me to quickly style a table and then copy the CSS.

The HTML Table Style Generator allows you to customize your tables with ease. No more manual CSS coding for every single table.

HTML Table Style Generator Interface

The Problem with Tables

We’ve all been there. You have a data-heavy project, and you need to present it in a clean, readable table. But then comes the CSS. Borders, padding, zebra striping, hover effects, text alignment… it adds up quickly.

I wanted a way to just “dial in” the look I wanted and get the code immediately.

Features

  • Live Preview: See your changes in real-time as you adjust the settings.
  • Color Palettes: Select from various pre-defined color schemes to match your site.
  • Customizable Spacing: Change font size, cell padding, and border width.
  • Zebra Striping: Easily add alternating row colors for better readability.
  • Row Hover Effects: Highlight rows as the user hovers over them.
  • Headers & Footers: Toggle table headers and footers on or off.
  • Clean CSS: Generates compressed CSS that is ready to be dropped into your project.

How it works

The generator UI gives you a set of sliders and color pickers. As you adjust them, the table in the center of the page updates. Once you are happy with the look, you click the “Generate Code” button.

Example Generated CSS

Here is a sample of the CSS that the generator produces:

.table-styler {
  font-family: Arial, Helvetica, sans-serif;
  color: #666;
  font-size: 12px;
  text-shadow: 1px 1px 0px #fff;
  background: #eaebec;
  margin: 20px;
  border: #ccc 1px solid;
  -moz-border-radius: 3px;
  -webkit-border-radius: 3px;
  border-radius: 3px;
  -moz-box-shadow: 0 1px 2px #d1d1d1;
  -webkit-box-shadow: 0 1px 2px #d1d1d1;
  box-shadow: 0 1px 2px #d1d1d1;
}

.table-styler th {
  padding: 21px 25px 22px 25px;
  border-top: 1px solid #fafafa;
  border-bottom: 1px solid #e0e0e0;
  background: #ededed;
}

.table-styler tr {
  text-align: center;
  padding-left: 20px;
}

.table-styler tr td:first-child {
  text-align: left;
  padding-left: 20px;
  border-left: 0;
}

.table-styler tr td {
  padding: 18px;
  border-top: 1px solid #ffffff;
  border-bottom: 1px solid #e0e0e0;
  border-left: 1px solid #e0e0e0;
  background: #fafafa;
}

.table-styler tr.even td {
  background: #f6f6f6;
}

.table-styler tr:hover td {
  background: #f2f2f2;
}

I hope this tool helps others as much as it has helped me. Feel free to leave a comment if you have any suggestions for improvements.


Legacy Archive

[The original post as it appeared on eligeske.com in 2011]

HTML Table Style Generator original post and comments

How often do you work with tables?

I work with them quite a bit and styling them can be tedious and buying a theme to utilize the html table layout and styles they’ve implemented can be overkill.

The other day I came across http://cssbuttongenerator.com while needing to make a quick nicely styled button (much props). The generator made styling an <a> tag so fast and easy. I was hoping to find a generator for html tables, so I scoured the web for a bit and came up with nothing, nada. Which led me to the choice of sacrificing my overly exciting normal weekend drudgery by creating, http://tablestyler.com a html table generator and css styler.

(Try out the http://tablestyler.com tool.)

Features:

  • Font Family
  • Table Border Width/Radius/Color
  • Cell Padding
  • Show/Hide Footer
  • Header Gradient Color/Text Color/Font-Bold
  • Show Column Lines Show/Hide/Color/Width
  • Show Hide/Footer
  • Alt Rows & Alt Row Colors
  • Add/Remove Pagination
  • Styling the Pagination
  • Preset Color Themes

Do you have any suggestions or features you would like to see added? I’d like to hear them. Use the comment area below as a drop box or discussion area for the Table Generator.

(Visited 101,892 times, 12 visits today)

Legacy Comments Archive

This post originally appeared on my old site and has been recovered from the archives. Below are the original comments from the community, including several technical discussions and CSS/JS fixes shared by users.

S
Steve
August 19, 2011

Thanks man. This is cool.

S
Simon Ferragne
August 30, 2011

Nice work !

M
Michael Beck
September 22, 2011

Thank you, your table generator is great. One question though, how can I make the odd number rows have the background highlight past the first three rows? I’ve added a link to my site with the table on it, you can see that the highlight only applies to the first three rows, nothing after. Thanks!

E
Eli Geske Author
September 22, 2011

Hey Michael, The reason the colors are not showing up in the other rows is because the class alt is missing from table row tag. Usually they would be added server side or with client side script. But it appears that you are just manually creating your HTML. So pick the row that should have the color and add class=”alt” to it.

M
Michael Beck
September 25, 2011

Yes, I’ve already tried using the alternating class=”alt” but it does not change. The issue must be in the CSS. I have this at the top of my CSS:

ul {
  list-style: none;
}

I’m guessing the “none” part is my problem. I’ll have to search around. Then the rest of the CSS is below.

.datagrid table {
  border-collapse: collapse;
  text-align: center;
  width: 100%;
}
.datagrid {
  font: normal 12px/150% Georgia, Times New Roman, Times, serif;
  background: #fff;
  overflow: hidden;
  -webkit-border-radius: 8px;
  -moz-border-radius: 8px;
  border-radius: 8px;
}
.datagrid table td,
.datagrid table th {
  padding: 6px 20px;
}
.datagrid table thead th {
  background: -webkit-gradient(
    linear,
    left top,
    left bottom,
    color-stop(0.05, #173622),
    color-stop(1, #275420)
  );
  background: -moz-linear-gradient(center top, #173622 5%, #275420 100%);
  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#173622', endColorstr='#275420');
  background-color: #173622;
  color: #ffffff;
  font-size: 13px;
  font-weight: bold;
  border-left: 1px solid #36752D;
}
.datagrid table thead th:first-child {
  border: none;
}
.datagrid table tbody td {
  color: #275420;
  border-left: 1px solid #c6ffc2;
  font-size: 12px;
  font-weight: normal;
}
.datagrid table tbody .alt td {
  background: #dfffde;
  color: #275420;
}
.datagrid table tbody td:first-child {
  border: none;
}
E
Eli Geske Author
September 26, 2011

Hi Michael. I was looking at your website that has the table on it. It appears that your implementation of the HTML is the problem and NOT the CSS. Look closely and you will notice you opened the table rows twice. What a row should look like: <tr class="alt"><td></td></tr> What a row should NOT look like: <tr class="alt"><tr><td></td></tr> Notice the extra <tr>

M
Michael Beck
September 26, 2011

:} Thank you! It works perfectly now! It was very kind of you to take the extra time to help me here. The table looks spectacular.

E
Eli Geske Author
September 27, 2011

The pleasure is all mine!

E
Eliot
November 14, 2011

Greetings from Toronto! I never post anything on these kinds of blogs. However, I’m an amateur when it comes to HTML/CSS despite doing tons of Web development with specific products (Adobe Flex, .NET, SQL, Google Maps and other GIS products) and came across your tool. Just wanted to let you know how helpful it was. Thank you very much!

E
Eli Geske Author
November 14, 2011

Awesome! Sorry to hear you are in Canada during winter, but glad you liked the tool!

P
Petri
November 20, 2011

Thanks! This is awesome tool. Saves so much time and creates cool custom made table themes. I will be using this in my open-source project.

g
gerry
February 21, 2012

how do you re size the table? no matter what i do i cant seem to resize the whole thing.

E
Eli Geske Author
February 22, 2012

Hi Gerry, Actually the table never gets resized for width. The div which contains it is what should be resized. For example: .datagrid { width: 500px }

g
gerry
February 22, 2012

wow thanks, that really helped a lot ,the table looks great. this site rock!

P
PlNG
April 1, 2012

Thanks for this tool, I was looking for a complex html table generator to make such a table for table testing. It didn’t do everything initially such as adding col and colgroup elements and rowspan attributes but it did most of the legwork. I’ve keyword stuffed this comment to bump you up in the ranks. Thanks again!

l
lifegear
April 10, 2012

Great html table generator tool! It would be cool to also have options number of rows / columns and table width. thanks again for a great tool.

E
Eli Geske Author
April 24, 2012

Yo lifegear, so right… will be looking into it soon.

T
Thomas Kainz
April 26, 2012

This a great tool – thank you. One thing, though, it seems though that while the output renders fine in Firefox, in IE 8, I’m not getting the rounded corners effect. Do you have any suggestions?

E
Eli Geske Author
April 26, 2012

Hi Thomas, glad you like it. IE just never plays nice and always waits years before coming to terms with the rest of the world. That being said, ie 8 and below do not recognize the attribute, border-radius. I believe I mentioned that in the short paragraph at the top of the tool. Now to answer your question on how to get that to work. You would have to do some images or use some JavaScript. But in all honesty, I prefer to forget that IE8 and below ever existed and start coding for the rest of the world. (upgrade to IE9). If I haven’t convinced you to forget the past I will be happy to share some links on achieving your goal. Just lemme know.

T
Thomas Kainz
April 30, 2012

While I agree whole-heartedly with you and your thoughts on IE8 – especially since Microsoft seems insistent on lagging behind everyone else – in spite of the fact that they have the resources to really be leading the industry in this respects. Unfortunately clients..and I have a few… whom don’t agree and insist that it work with IE8 so if you have any practical examples of JavaScript code that won’t break your css for the other ‘normal’ browsers, by all means, steer me in that direction. I’ll be searching myself and if I find something I’ll post it so you don’t waste your time needlessly. Many thanks again!

M
Mark
May 12, 2012

great tool – but turning the footer off still leaves a little section at the bottom and sure how to resolve…

M
Mark
May 12, 2012

I would add the ability to set the row line color and thickness.

w
web designer sydney
May 15, 2012

great tool…very easy and quick…like it a lot

D
David
June 1, 2012

Halle-freaking-lujah! I had made hack version of my own, but it wasn’t quite cutting it and definitely wasn’t ready for the public. This is superb! 1 Main addition: Colgroups in case styling that way is more effective.

D
David
June 1, 2012

I’ve been thinking that there needs to be some better table generators/tools in general. Particularly pertaining to SEO. I feel like tables get bad rep due to their poor use in the past, but with title tags, proper layouts, etc, they aren’t half bad. They just take a bit to get used to. (As if CSS is all that simple. ) What I’m saying is, if I were to make a table generator geared towards SEO, and potentially specific for content creation inside the table, could I integrate your tool? Either give you credit, let you run it, or in some other fashion? Again, I’ve sort of begun but I don’t exactly have a commitment to finish anytime soon, so it may not actually happen. Either way, I highly appreciate your work! Thanks! ~David

J
Josh
June 25, 2012

Really nice tool, and for the most part, the default style is really nice already. I am making small tweaks with the GUI controls, and one nice addition might be the ability to import a modified sheet that was generated by the tool after some tweaks were made from the GUI controls.

B
Bear
July 2, 2012

Thank you, nice done. I’ll make sure to give the tool some link appreciation :-) Pingback: Delicious Bookmarks for July 2nd through July 3rd « Lâmôlabs

D
Donnie
July 25, 2012

Great tool.. Is there an easy way to get data into the table without manually entering it. I have a table with 300 rows and it would be difficult to modify each row.

E
Eli Geske Author
July 25, 2012

Is the data the same for each row? If not please explain to me where the data is coming from.

K
Kevin
July 29, 2012

A great tool saves loads of time. an enhancement would be the option to set column widths. Any ideas how I could do this? Not very techie when it comes to css so need all the help I can get. Kevin

m
mari
July 30, 2012

hello… im dont want to use the alternate rows, but i want to use row line color only.. how can i do that. please help me

J
Jenny
August 5, 2012

Amazing tool, just reduces my work time into quarter. Thanks a lot

J
JBravo
August 6, 2012

This is a super tool! I’m a beginner and I find it really helpful. Just wanted to ask, how do I get the pagination to work? Right now clicking on the footer does nothing. Also, how do I limit the number of rows per page? I have 30 rows which I want to show 10 rows at a time. Thanks in advance!

J
JBravo
August 6, 2012

Is there anyway to resize the columns?

E
Eli Geske Author
August 21, 2012

@Josh – I really like that Idea and will be giving that some thought here in the near future. Thanks! @Mark – The row lines have been added today. version 1.3 released. @Donnie- Thanks! Glad you like it. I will put that in my brain and kick it around on the easiest way to implement.

A
Andrew Green
September 2, 2012

Just a quick note to say thanks for this free tool. I coded a back-end reporting tool where only I see the table of data, but it was really quick, and easy to make it look cool rather than incredibly dull using your code.

G
Gino
September 5, 2012

Hi, I love your tablestyler! Great tool, thank you! Can you please help me with integrating the css into my stylesheet.css? I don’t know how do it :-( Thanks in advance!

K
Kevin
September 10, 2012

How do you override the table width. Cannot seem to get the outermost border to go away.

K
Karan
October 8, 2012

Thanx but its not working on blogger properly !

O
Oddunity
October 15, 2012

Loving you CSS output … Outstanding work! I’ve only found a few tools that will accomplish this so easily and yours is by far the best :) Although ….a nice drop shadow would be cool around the table frame .. hehe

S
Scott H
October 26, 2012

This is a great little tool. Nicely done – good job.

J
Jan
October 26, 2012

I’ve been trying a few generators over the last couple of days but none of them come close to this one. Great work! Allowing extra columns and rows within the designer is something all other developers of css generators (that I’ve come across) have missed out. Thanks, it’s a massive help!

g
gunawan
November 9, 2012

the code should be in good order

S
S Lal
November 10, 2012

Your work is just wonderful and awesome. It will do tons of good for everybody around. Your effort is admirable.

V
Vanessa
December 3, 2012

What a super cool tool!!! Can you help me get it to work properly? Once I get the code generated, is it simply a matter of copy and paste, because it is not showing up. The table I am referring to can be seen on my site on the sidebar under the “Popular Posts” heading. I pasted the html in that widget area and then pasted the css code in my css file. My speculation is that there is something left out that is keeping the two from matching up, so that the table looks like a standard table and not like the way I customized it.

E
Eli Geske Author
December 3, 2012

I see that you pasted your css into custom.css of the wordpress theme. WordPress gets kind of messy with the more plugins added. The .datagrid class is not being read by the DOM (web browser), probably due to some issues in syntax in the file. My suggestion would be to put this directly into the tag of your theme file.

V
Vanessa
December 3, 2012

Are you referring to custom_functions.php file?

E
Eli Geske Author
December 4, 2012

Depending on how the template is structured, there should be an index.php or header.php perhaps in your theme folder.

M
Michael
December 20, 2012

Hello, What a great tool! My only thing is how do you get the columns to be equal in size? The middle column is larger. Thx :-)

R
Robert Gehlis
December 23, 2012

Hey there, Nice Table and works great, just one thing. When having more than one column, it just so happens that the “thead” th’s develop a border around them from the second column onwards. Just put “border: none;” in you data grid class before you’re deklaring it to have a border on the left. Might not be so obvoius to inexperienced css users out there.

M
Mike Jones
January 16, 2013

I like the table but how and the heck do i get it to work on my web page, I know nothing about css. I see that by pasting the html code does nothing without the .css and I don’t know where to put the .css

m
martzell
January 31, 2013

Hello, great tool. Thanks for that. Is it possible to get the design for tables fitting to content, auto-width instead of width: 100%? I can’t get it perfect: http://www.martzell.de/2013/01/carsharing-vergleich.html Best regards from Germany, Martin

S
Steve
February 1, 2013

Great Tool ! But one thing, when adding / setting the rows or column with color lines it seems that the html generator is not displaying the html code. Can someone please advise if we are doing something wrong or is this an issue with the generator. Thanks

E
Eli Geske Author
February 1, 2013

Hi Martin, Add this to your css. .datagrid table { width: 100%; }

m
martzell
February 1, 2013

Hi eligeske, I prefer a minimal width for tables and can’t get it perfect. My web site have no max-width yet, so tables would be to stretched when set to width: 100 %.

c
chrysler5910@gmail.com
February 12, 2013

hi! great tool.. i have a problem though in populating data from database to the table.. it seems it is populating in just 1 row..

p
peter
March 11, 2013

Hi eligeske, How do i add text under these cells in between the 2 rows….

<table style="width: 970px; height: 69px;" border="0">
  <tr>
    <td>MOUNTINGS EQUIPMENT</td>
    <td>MOUNTINGS EQUIPMENT</td>
    <td>MOUNTINGS EQUIPMENT</td>
    <td>MOUNTINGS EQUIPMENT</td>
  </tr>
  <tr>
    <td>MOUNTINGS EQUIPMENT</td>
    <td>MOUNTINGS EQUIPMENT</td>
    <td>MOUNTINGS EQUIPMENT</td>
    <td>MOUNTINGS EQUIPMENT</td>
  </tr>
</table>

Regards Peter

B
Blub
March 11, 2013

Hello I’m using 2 columns and i put the table in a smaller div…. How can i make the line between the columns exactly be in the middle? after i entered text into the table, the line dividing the columns is not in the middle of the table anymore….. any idea? And what can i do to make the look of links match the look of the text?

E
Eli Geske Author
March 12, 2013

Hi, If you are using only two columns, look inside the thead and put width=”50%” in the first th. This should fix your issue, unless the width of your container is too small.

S
Steffen
March 19, 2013

Great! It was just what I was looking for. A great tool saved me loads of time. Thanks

a
abc
March 22, 2013

excellent work dear!

S
Steve
March 22, 2013

Forgive my ignorance: How do I adjust the width of specific columns? Some of my columns need to be a few dozen characters wide, and others only a few characters wide. When I type a few dozen characters into the cell, it expands the row vertically. I need it to make the column wider instead. Also, how do I set the overall width of the table? I added: .datagrid {width: 800px} per your instructions above, and while that did limit the table to 800px in width, it did so by cropping the rightmost edge of table (so I lost one of my columns and 20% of the one next to it). I appreciate your help. Let me know if you need screenshots or anything.

I
Ivan
March 27, 2013

how to use this in asp.net griview

c
cy
March 30, 2013

august 6th 2012: “This is a super tool! I’m a beginner and I find it really helpful. Just wanted to ask, how do I get the pagination to work? Right now clicking on the footer does nothing.” I have the same question. I know about some scripts that can make it work, but how to implement them? And I can’t get the rows/columns to become more or less :(

c
cy
April 1, 2013

I got it, but I had some help of a friend: So here is how you make it work with the js code inline (I had to do it that way) In Css change: .datagrid table tfoot li a To: .datagrid a This at beginning of head:

<!-- here comes your CSS -->

make the table like this:

<table id="tabelle">
  <thead>
    <tr>
      <th>header</th>
      <th>header</th>
      <th>header</th>
      <th>Link</th>
      <th>header</th>
      <th>header</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>1</td>
      <td>data</td>
      <td>data</td>
      <td>data</td>
      <td>data</td>
      <td>data</td>
    </tr>
    <tr>
      <td>2</td>
      <td>data</td>
      <td>data</td>
      <td>data</td>
      <td>data</td>
      <td>data</td>
    </tr>
  </tbody>
</table>

This before closing body:

<div id="paging">
  <form>
    <img src="first.png" class="first" />
    <img src="prev.png" class="prev" />
    <input type="text" class="pagedisplay" />
    <img src="next.png" class="next" />
    <img src="last.png" class="last" />
    <select class="pagesize">
      <option selected="selected" value="5">5</option>
      <option value="10">10</option>
      <option value="15">15</option>
      <option value="20">20</option>
    </select>
  </form>
</div>

<script>
  $(document).ready(function () {
    $("#tabelle")
      .tablesorter({ sortList: [[0, 0]] })
      .tablesorterPager({ container: $("#paging"), size: 5 });
  });
</script>

bye

c
cy
April 1, 2013

well that comment didn’t turn out the way I hoped

p
pooja
April 25, 2013

This is an awesome tool… really great.. thank you!!

A
Arslan AR
April 30, 2013

Hey eligeske I See Your Table generator Its A Awesome Piece of Art I want it to Add im My Blogger Site But Can’t Tell me How i Can Add this table To my Blogger Post ?? Please Immediately When i Add the html code to blogger post and See in Compose Section I Can See Only Normal text No Styling my Browser is Also Latest So Tell me Whats the Problem??????

l
leson
May 24, 2013

Just wanted to say thanks!

L
Leon
June 5, 2013

Awesome tool, really helped me! thank you! I have one problem: how can i make some colomns bigger and some smaller? Is that possible somehow?

L
Lotty
July 4, 2013

This is a fantastic tool… but i cant see an option to center the text?

b
bagus
January 20, 2014

very usefull and very cool

M
Marianne
February 14, 2014

This is a great tool! Is this also available as a tool to download so that one can save a table with customized color scheme instead of retyping all the values again online?

E
Eli Geske Author
February 14, 2014

Hi Marianne! This is something that has been on my mind for a while!!! I guess I’ll stop slacking and add that ability to save. Glad you like it!!!