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.

5,697 comments

  1. arbitrage sports betting

    Totals payouts are based on the money line odds shown in the brackets beside
    the total, just like we covered in the money line example above.

  2. Jolly CBD Review

    Thanks on your marvelous posting! I seriously enjoyed
    reading it, you happen to be a great author. I will make certain to bookmark your blog and definitely will come back from now on.
    I want to encourage you continue your great posts, have a nice evening!

    My website Jolly CBD Review

  3. Jolly CBD Review

    Hey there! I know this is somewhat off topic but I was wondering which blog
    platform are you using for this website? I’m getting fed up of WordPress because I’ve had issues with hackers and
    I’m looking at options for another platform.
    I would be great if you could point me in the direction of a good platform.

    Feel free to visit my webpage Jolly CBD Review

  4. sports betting help

    Can’t be on the Pennsylvania Gaming Control Board Self-exclusion or State Exclusion lists.

  5. CamHandy Rear View DVR

    Good write-up, I am regular visitor of one’s blog, maintain up the excellent operate,
    and It’s going to be a regular visitor for a long
    time.

    Look at my web blog CamHandy Rear View DVR

  6. freeonlineporncam.com

    To get to know somebody on the Internet you just need to log in onto a social
    site or chat. In this new technology century the Internet will become
    your faithful companion. You can browse the internet for e-books and
    video on yoga. This is Generally referred to
    inner listening and it is very vital when Exercising yoga for calories burned.
    It is also very vital that you consider psychological and physiological components of dieting, exercising and motivation for doing well
    weight control. I’m looking forward to doing a boy/boy/girl scene.

    Particular game publishers’ final decision to get questionable games
    rated seems to reveal that they are certainly not created for young kids.
    Video game dependency is an additional social aspect of gaming to get critique as it
    can certainly have a destructive influence on health and on social relations.
    The growth of computer games within the decade have long been a source
    of controversy, particularly linked to the violence that
    has been often related to video gaming in general.

  7. ultimate sports betting strategies

    In the context of sports betting, implied probability is
    what the odds recommend the chances of any given outcome
    happening are.

  8. Jolly CBD Review

    Thanks for any other informative website. Where else could I get that type of information written in such a perfect way?
    I have a project that I’m simply now operating on, and
    I’ve been at the glance out for such info.

    Also visit my web site … Jolly CBD Review

  9. Jolly CBD Gummies Reviews

    Hello! I know this is kind of off topic but I was wondering which blog platform are you using for
    this site? I’m getting sick and tired of WordPress because
    I’ve had issues with hackers and I’m looking at alternatives for another platform.
    I would be great if you could point me in the
    direction of a good platform.

    Here is my website … Jolly CBD Gummies Reviews

  10. 유튜브 음원 추철

    If you are going for finest contents like myself, simply go to see this
    website everyday since it offers quality contents, thanks

  11. Isidro

    Thank you for sharing your info. I truly appreciate your efforts and
    I am waiting for your further post thank you once again.

  12. web judi Slot online

    An outstanding share! I have just forwarded this onto a coworker who
    had been conducting a little research on this.

    And he in fact ordered me lunch due to the fact that I stumbled upon it for
    him… lol. So allow me to reword this…. Thanks for
    the meal!! But yeah, thanx for spending some time to talk about
    this matter here on your internet site.

  13. betting on sport

    This ruling is a welcome transform for the sports television sector,
    which is facing stress from streaming services, social networks, and video games.

  14. CamHandy Dashcam

    Usually I do not learn article on blogs, however I would like to
    say that this write-up very compelled me to take a look at and do so!

    Your writing style has been surprised me. Thank you, quite nice post.

    My homepage CamHandy Dashcam

  15. 무료 음원 유튜브

    Greetings from Carolina! I’m bored to death at work so I decided to browse your blog on my iphone
    during lunch break. I really like the knowledge
    you provide here and can’t wait to take a look when I get home.
    I’m surprised at how quick your blog loaded on my mobile
    .. I’m not even using WIFI, just 3G .. Anyhow, excellent blog!

  16. CamHandy Review

    Very rapidly this web page will be famous amid all blogging and
    site-building viewers, due to it’s pleasant content

    Here is my blog post … CamHandy Review

  17. Testoryze Male Performance Matrix

    Definitely consider that which you said. Your favourite
    reason seemed to be at the web the easiest factor to take into account
    of. I say to you, I definitely get annoyed whilst other folks consider
    issues that they just do not know about. You managed to hit the nail upon the top and outlined
    out the whole thing with no need side-effects
    , other folks could take a signal. Will probably be again to
    get more. Thanks

    Also visit my web site … Testoryze Male Performance Matrix

  18. Rodrick

    Excellent write-up. I definitely appreciate this site. Stick with it!

  19. 진격의 거인 1화 애니 다시보기

    Hi there, just became aware of your blog through Google, and found that it
    is truly informative. I am gonna watch out for brussels.
    I will be grateful if you continue this in future.
    Lots of people will be benefited from your writing. Cheers!

Leave a Reply

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