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.

7,765 comments

  1. 파라오카지노

    Woah! I’m really digging the template/theme of this site.
    It’s simple, yet effective. A lot of times it’s challenging to get that
    “perfect balance” between user friendliness and visual appearance.
    I must say you have done a superb job with this. In addition,
    the blog loads extremely fast for me on Internet explorer.
    Outstanding Blog!

  2. 넷마블 바카라

    I really love your website.. Great colors & theme.
    Did you create this site yourself? Please reply back as I’m attempting
    to create my very own site and would like to know where you
    got this from or what the theme is called.
    Thanks!

  3. childrens party entertainm

    Thanks for one’s marvelous posting! I genuinely enjoyed reading it, you may be a great author.
    I will make sure to bookmark your blog and definitely will come back from now
    on. I want to encourage you to definitely continue your great
    work, have a nice day!

  4. 퍼스트카지노

    I every time used to read piece of writing in news papers but now as
    I am a user of internet so from now I am using
    net for content, thanks to web.

  5. Frederic Hodgens

    Thanks , I’ve just been looking for information about this subject for ages and yours is the greatest I have discovered so far. But, what about the conclusion? Are you sure about the source?

  6. 퍼스트카지노

    Wonderful blog! Do you have any suggestions for aspiring writers?
    I’m hoping to start my own site soon but I’m
    a little lost on everything. Would you advise starting with a free platform like WordPress or go for a paid option? There
    are so many choices out there that I’m completely confused ..

    Any suggestions? Thanks!

  7. 퍼스트카지노

    Hello There. I found your blog using msn. This is a
    very well written article. I will be sure to bookmark it and return to read more of your useful information. Thanks for the post.
    I’ll certainly comeback.

  8. online betting

    I am genuinely delighted to read this blog posts which
    consists of lots of helpful information, thanks for providing such statistics.

  9. 파라오카지노

    Hello, i think that i saw you visited my site so i came to “return the favor”.I’m trying to find things to improve my website!I suppose its ok to use a few of your ideas!!

  10. 벳365

    Hi there! I’m at work surfing around your blog from my new
    iphone 4! Just wanted to say I love reading through your blog and look forward to all your posts!
    Carry on the superb work!

  11. 007카지노

    Thanks in support of sharing such a pleasant opinion, post is fastidious, thats why i have read
    it completely

  12. Porfirio Socha

    Good write-up, I’m normal visitor of one’s web site, maintain up the excellent operate, and It is going to be a regular visitor for a long time.

  13. Karl

    I think this is one of the most significant info for me. And i
    am glad reading your article. But wanna remark on few general things, The site style is wonderful, the articles is really excellent : D.
    Good job, cheers

  14. 퍼스트카지노

    You are so interesting! I don’t think I’ve read through a single thing like this before.

    So good to find somebody with some original thoughts on this
    subject matter. Seriously.. many thanks for starting
    this up. This web site is something that is needed on the internet, someone with a little originality!

  15. 카지노사이트

    When someone writes an article he/she maintains the idea of a
    user in his/her mind that how a user can know it. Thus that’s why this article is amazing.
    Thanks!

  16. 샌즈카지노

    Great post. I was checking continuously this weblog and I’m impressed!
    Very helpful information specially the remaining part 🙂 I take care of such info
    much. I was seeking this particular info for a very
    long time. Thank you and best of luck.

  17. Sabine Martyr

    Hey there! Do you use Twitter? I’d like to follow you if that would be okay. I’m absolutely enjoying your blog and look forward to new updates.

  18. Infinite Percent Partners

    When I originally commented I clicked the “Notify me when new comments are added” checkbox and now each time a comment is added I get four e-mails with the same comment. Is there any way you can remove me from that service? Bless you!

  19. ポーカー

    I have been exploring for a little for any high quality articles or blog
    posts in this kind of space . Exploring in Yahoo I eventually stumbled upon this web site.
    Studying this information So i am glad to convey that I’ve an incredibly excellent uncanny feeling I
    came upon exactly what I needed. I most no doubt will make sure
    to don?t disregard this site and give it a glance on a continuing basis.

  20. Asap Appliance Repair Charlotte NC

    Magnificent web site. Lots of useful information here. I am sending it to several pals ans additionally sharing in delicious. And of course, thank you to your effort!

  21. 코인카지노

    I don’t know whether it’s just me or if everybody else experiencing problems with your site.
    It appears as if some of the written text within your content are
    running off the screen. Can somebody else please provide feedback and
    let me know if this is happening to them too?
    This might be a problem with my browser because I’ve had this happen before.
    Appreciate it

  22. hydroxychloroquine and kidney function

    Today, I went to the beach front with my kids. I found a sea shell and gave it to my 4 year old
    daughter and said “You can hear the ocean if you put this to your ear.” She put the shell to her ear and screamed.
    There was a hermit crab inside and it pinched her ear.
    She never wants to go back! LoL I know this is completely off
    topic but I had to tell someone! https://herreramedical.org/hydroxychloroquine

  23. Advanced Appliance Repair Charlotte NC

    What’s Happening i’m new to this, I stumbled upon this I have found It absolutely helpful and it has aided me out loads. I hope to contribute & assist other users like its aided me. Great job.

  24. california tourism

    I loved as much as you will receive carried out right here.

    The sketch is attractive, your authored subject matter stylish.
    nonetheless, you command get got an shakiness over that you wish be delivering the following.
    unwell unquestionably come further formerly again since exactly the same nearly a lot often inside case you shield this increase.

  25. 원엑스벳

    Hi there, I discovered your site by the use of Google whilst searching for a related
    topic, your website got here up, it appears good.

    I’ve bookmarked it in my google bookmarks.
    Hi there, just became aware of your weblog via Google, and found that it is truly informative.
    I’m gonna watch out for brussels. I’ll be grateful if you continue this in future.
    A lot of other people will be benefited out of your writing.
    Cheers!

  26. 카지노사이트

    Spot on with this write-up, I actually believe this website needs much
    more attention. I’ll probably be back again to read through
    more, thanks for the info!

  27. 007카지노

    Hi i am kavin, its my first occasion to commenting anyplace,
    when i read this post i thought i could also make comment due to
    this brilliant post.

  28. Bunny Najar

    You actually make it seem really easy along with your presentation however I in finding this matter to be really one thing that I believe I’d by no means understand. It sort of feels too complicated and extremely huge for me. I’m looking forward to your next publish, I will attempt to get the cling of it!

Leave a Reply

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