HTML Tables: Here’s How To Make Your First Table

Short Explanation About HTML Table

  • A table is defined using the <table> element, and contains a number of table cells ( <td>, for “table data” ) which are organized into table rows ( <tr>). The markup (HTML code) for a table is always based on rows, never columns.
  • Table cells which act as column headers or row headers should use the <th> (table header) element.
  • Table cells can be merged using the colspan and rowspan attributes.
  • Tables can be broken into sections using the following elements:
    • <thead> — Table header
    • <tbody> — Table body
    • <tfoot> — Table footer
  • A caption can be added to a table using the <caption> element.
  • You can use <col> and <colgroup> to define table columns for styling. However, there are a number of limitations with this practice.
  1. Table Code Sample: Simple Table

    Here is an example of a simple table. Copy this code into your editor and run it in your browser. If you haven’t got one, check my earlier post about Top 5 PHP Editor (IDE) for Web Developers.

    <table>
    	<tr>
    		<th>Name</th>
    		<th>Favorite Color</th>
    	</tr>
    	<tr>
    		<td>Bob</td>
    		<td>Yellow</td>
    	</tr>
    	<tr>
    		<td>Michelle</td>
    		<td>Purple</td>
    	</tr>
    </table>

  2. Table Code Sample: Complex Table

    <table>
      <caption>A complex table</caption>
      <thead>
        <tr>
          <th colspan="3">Invoice #123456789</th>
          <th>14 January 2025
        
        </tr>
        <tr>
          <td colspan="2"><strong>Pay to:</strong><br> Acme Billing Co.<br> 123
            Main St.<br> Cityville, NA 12345</td>
          <td colspan="2"><strong>Customer:</strong><br> John Smith<br> 321
            Willow Way<br> Southeast Northwestershire, MA 54321</td>
        </tr>
      </thead>
      <tbody>
        <tr>
          <th>Name / Description</th>
          <th>Qty.</th>
          <th>@</th>
          <th>Cost</th>
        </tr>
        <tr>
          <td>Paperclips</td>
          <td>1000</td>
          <td>0.01</td>
          <td>10.00</td>
        </tr>
        <tr>
          <td>Staples (box)</td>
          <td>100</td>
          <td>1.00</td>
          <td>100.00</td>
        </tr>
      </tbody>
      <tfoot>
        <tr>
          <th colspan="3">Subtotal</th>
          <td>110.00</td>
        </tr>
        <tr>
          <th colspan="2">Tax</th>
          <td>8%</td>
          <td>8.80</td>
        </tr>
        <tr>
          <th colspan="3">Grand Total</th>
          <td>$ 118.80</td>
        </tr>
      </tfoot>
    </table>

What You Can Do Next

There is a CSS template to make a good styled HTML table very easily called Bootstrap. Simply load the bootstrap CSS in your HTML using <link> tag, and then use classes provided by bootstrap to style your table. For example, you can customize color, add striped rows to your table using one single parent class, nicely styled borderless table, hoverable rows, and many more. Try it yourself by reading Bootstrap documentation about tables here.

Keep in mind that example tables in this post is just static tables, meaning that the content inside the tables are hardcoded. When making a table in a site, commonly we must make the data dinamic. For example, the data is taken from database and the content keeps changing. I will explain this in the next post about how to make a dynamic table using PHP and HTML.

10,904 comments

  1. andar bahar online

    Why viewers still use to read news papers when in this technological globe all
    is existing on web?

  2. 안전한 카지노

    Excellent post. I will be dealing with some of these issues as well..

  3. オンラインカジノ

    Heya i’m for the first time here. I came across this board and I find
    It really helpful & it helped me out much. I am hoping to offer something again and aid others such as you aided me.

  4. Titanium TV

    I am really impressed together with your writing abilities as well as with the
    structure to your weblog. Is this a paid subject or did you modify it your self?

    Anyway stay up the nice high quality writing, it’s uncommon to see a great weblog like this one today..

  5. 다파벳

    For most up-to-date information you have to pay a visit web and on web I
    found this web page as a finest website for latest updates.

  6. 코인카지노

    I am regular reader, how are you everybody? This post posted at this site
    is actually good.

  7. credit by examination

    Hi, Neat post. There is an issue together with your site in web explorer, might
    test this? IE nonetheless is the marketplace chief
    and a large element of people will pass over your excellent writing because of this problem.

  8. レオベガス 出金 遅い

    Hurrah! At last I got a webpage from where I be capable
    of in fact obtain valuable facts regarding my study and
    knowledge.

  9. 제왕카지노

    Way cool! Some extremely valid points! I appreciate you penning this post plus the rest
    of the site is also really good.

  10. xo 카지노

    Hi, I desire to subscribe for this website to obtain latest
    updates, thus where can i do it please help out.

  11. 윌리엄힐

    Hello there! Would you mind if I share your blog with my twitter group?

    There’s a lot of people that I think would really enjoy your
    content. Please let me know. Thank you

  12. casino game

    It is the best time to make some plans for the future and it’s time to
    be happy. I have read this post and if I could I wish to
    suggest you few interesting things or tips. Perhaps you could write next
    articles referring to this article. I desire to read more things
    about it!

  13. casino games

    I blog quite often and I really thank you for your content.

    The article has really peaked my interest. I am going to take a note of
    your website and keep checking for new details about
    once a week. I opted in for your Feed as well.

  14. Paddy Power

    I’m really impressed along with your writing talents and also with the layout
    to your blog. Is this a paid subject matter or did you customize it yourself?
    Either way keep up the excellent quality writing,
    it’s uncommon to peer a nice weblog like this one these days..

  15. online furniture stores

    We are a gaggle of volunteers and starting a new scheme in our community.
    Your site offered us with useful info to work on. You’ve done an impressive task and our entire
    neighborhood can be thankful to you.

  16. ビットスターズ

    Simply desire to say your article is as surprising.
    The clarity in your put up is simply cool and that i could think
    you are a professional on this subject. Fine along with your permission allow me
    to grab your feed to stay up to date with approaching post.
    Thank you one million and please carry on the rewarding work.

  17. ライブカジノハウス

    Hi there! This blog post could not be written much better!
    Reading through this article reminds me of
    my previous roommate! He constantly kept talking about
    this. I will forward this article to him. Fairly certain he will have a very good read.
    Thanks for sharing!

  18. 우리카지노

    An impressive share! I’ve just forwarded this onto a coworker who was doing
    a little research on this. And he actually ordered me breakfast because
    I discovered it for him… lol. So let me reword this….
    Thank YOU for the meal!! But yeah, thanks for spending the time to discuss this topic here on your internet site.

  19. Blackjack

    Whats up are using WordPress for your site platform? I’m new to the blog world but I’m trying to get started and
    create my own. Do you need any coding knowledge to make your own blog?
    Any help would be greatly appreciated!

  20. slot games

    I have to thank you for the efforts you’ve put in writing this site.
    I’m hoping to see the same high-grade content from you
    in the future as well. In truth, your creative writing
    abilities has motivated me to get my own site now 😉

  21. thai tea milk

    I got this web page from my friend who informed me concerning this web
    site and at the moment this time I am visiting this web page and reading very informative articles or reviews at this place.

  22. adult dog food

    Hey There. I found your weblog the usage of msn. That is a very well
    written article. I’ll make sure to bookmark it and come
    back to read extra of your useful info. Thank you for the
    post. I will definitely comeback.

  23. バカラ カジノ

    I am really grateful to the holder of this website who has shared this impressive piece
    of writing at at this time.

  24. 인터넷 카지노

    It’s remarkable to visit this site and reading the views of all friends concerning this article, while I am
    also eager of getting knowledge.

  25. 베트웨이

    Howdy just wanted to give you a quick heads up. The text in your content seem to be
    running off the screen in Chrome. I’m not sure if this is a formatting issue
    or something to do with browser compatibility but
    I figured I’d post to let you know. The style and design look great though!
    Hope you get the issue resolved soon. Kudos

  26. 솔레어카지노

    Have you ever considered about including a little bit more than just your articles?
    I mean, what you say is fundamental and everything. Nevertheless just imagine
    if you added some great photos or video clips to give
    your posts more, “pop”! Your content is excellent but with images
    and clips, this site could definitely be one of
    the greatest in its niche. Wonderful blog!

  27. example of collage

    I’ve read several excellent stuff here. Definitely value
    bookmarking for revisiting. I wonder how a lot effort you set to make
    such a fantastic informative web site.

  28. good life massage

    Great web site you have here.. It’s difficult to
    find good quality writing like yours nowadays. I truly appreciate people like you!
    Take care!!

  29. 더나인카지노

    Please let me know if you’re looking for a article writer for your blog.
    You have some really good articles and I feel I would be a good asset.
    If you ever want to take some of the load off, I’d really like to write some articles for your blog in exchange for a link back
    to mine. Please blast me an e-mail if interested. Many thanks!

  30. 우리카지노

    Hey there! I know this is somewhat off topic but
    I was wondering if you knew where I could get a captcha plugin for
    my comment form? I’m using the same blog platform as yours and I’m having trouble finding one?
    Thanks a lot!

Leave a Reply

Your email address will not be published. Required fields are marked *