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.

14,463 comments

  1. pa lottery powerball

    I don’t know if it’s just me or if everybody else encountering issues with your website.
    It looks like some of the text in your content are running off the screen. Can someone else please
    comment and let me know if this is happening to them as well?
    This may be a issue with my browser because I’ve had this happen previously.
    Appreciate it

  2. pmedonline

    Its like you learn my thoughts! You seem to understand a lot
    about this, like you wrote the book in it or something.

    I think that you could do with some % to power the message home a bit, however
    instead of that, that is great blog. An excellent read.
    I’ll certainly be back.

  3. westwood building materials

    Someone essentially assist to make significantly articles I would state.
    This is the first time I frequented your website page and to this point?
    I amazed with the research you made to create this particular
    publish amazing. Fantastic job!

  4. 카지노사이트

    Hello! I just wanted to ask if you ever have any issues with hackers?
    My last blog (wordpress) was hacked and I ended up losing a few months of hard work due to no backup.

    Do you have any solutions to prevent hackers?

  5. stellar age mmo strategy mod apk

    You can definitely see your expertise within the work you write.
    The arena hopes for more passionate writers such
    as you who are not afraid to say how they believe.
    All the time follow your heart.

  6. king of sails ship battle hacked version

    Wonderful website. A lot of useful information here.
    I’m sending it to a few friends ans also sharing in delicious.

    And obviously, thank you to your effort!

  7. 007 카지노 로얄 보기

    I was recommended this web site by my cousin. I am not sure
    whether this post is written by him as nobody else know such detailed about my problem.
    You are wonderful! Thanks!

  8. https://b28rlibw3.blogspot.com/

    Hello to every body, it’s my first visit of this
    blog; this website carries remarkable and in fact fine stuff for visitors.

  9. tải cờ tướng

    I really like your blog.. very nice colors & theme. Did
    you design this website yourself or did you hire someone
    to do it for you? Plz reply as I’m looking to create my own blog and would like to know
    where u got this from. thanks a lot

  10. jQ6K5dC9wT2

    you’re really a just right webmaster. The website loading velocity is
    amazing. It sort of feels that you’re doing any distinctive trick.

    Moreover, The contents are masterpiece. you have done a excellent
    task in this matter!

  11. https://37idphlhcb3.blogspot.com/

    Everything is very open with a clear description of the issues.
    It was definitely informative. Your site is very helpful.
    Thank you for sharing!

  12. https://m3hyrx4jv.blogspot.com/

    This is really interesting, You are a very skilled blogger.
    I’ve joined your rss feed and look forward to seeking more of your wonderful post.
    Also, I’ve shared your site in my social networks!

  13. Strapon

    It’s a pity you don’t have a donate button! I’d definitely donate to this fantastic blog!
    I guess for now i’ll settle for book-marking and adding your RSS
    feed to my Google account. I look forward to
    brand new updates and will talk about this site with my Facebook group.
    Chat soon!

  14. Shota

    This design is wicked! You definitely know how to keep a reader entertained.
    Between your wit and your videos, I was almost
    moved to start my own blog (well, almost…HaHa!) Great job.
    I really loved what you had to say, and more than that, how you presented it.

    Too cool!

  15. minecraft servers

    Howdy would you mind letting me know which webhost you’re working with?
    I’ve loaded your blog in 3 different web browsers and I must say this blog
    loads a lot quicker then most. Can you recommend a good web hosting provider at a honest price?
    Thanks, I appreciate it!

  16. tT2K6iQ5eE7

    Great post. I’m facing some of these issues as well..

  17. connors farm

    I am curious to find out what blog platform you’re working with?

    I’m experiencing some minor security issues with
    my latest website and I’d like to find something more safeguarded.
    Do you have any recommendations?

  18. https://gregoryj87holloway.blogspot.com/

    No matter if some one searches for his vital thing, therefore he/she needs to be available that in detail, thus that thing is maintained over here.

  19. 더킹 카지노 조작

    It’s difficult to find knowledgeable people for this subject,
    however, you sound like you know what you’re talking about!
    Thanks

  20. slim 36 et vinaigre de cidre

    Thanks for finally writing about > HTML Table Make Your First Table – Dryan Christoph Personal Site < Loved it!

  21. sports bet

    I got this website from my buddy who shared with me on the topic of this
    web site and now this time I am visiting this web
    page and reading very informative articles or reviews
    at this time.

  22. http://ozakit.o.oo7.jp/cgi-bin/ezmixed.cgi

    You made some really good points there. I looked on the net
    for more info about the issue and found most individuals will
    go along with your views on this web site.

  23. Green Fast Diet Keto

    For most recent information you have to go to see world wide web and on world-wide-web I found this web site
    as a best web site for hottest updates.

  24. 토토메이저

    Currently it seems like Drupal is the top blogging platform available right now.
    (from what I’ve read) Is that what you are using on your blog?

    my web site: 토토메이저

  25. Visit Website

    Internet is filled with numerous hundreds free games that are enjoyed by people from all over
    the globe. No matter what age or occupation everyone enjoys the many games on the internet that become a passion for players who spend much time playing
    them.The interest in these games is so high that new titles are being
    churned out every minute. There’s a lot of variety for online gaming enthusiasts that choose to spend
    time every morning choosing their top games online and be relaxed.
    If you select the right online gaming site, you will enjoy an almost-ad-free gaming experience with no irritating pop-ups that spoil your game for you.
    The games are divided into columns or pages with the most popular,
    popular with critics, the latest fashion games and so on.
    Technology’s advancement in the present has allowed developers to create
    a similar console gaming experience for their users.
    For beginners in gaming games played online are the most suggested form as the games on offer are
    relatively simple to learn and provide an excellent entertainment value for the typical user.Regardless however, the reality
    that a majority games available online are cost-free and often smaller than their desktop and console counterparts.

    However, the difference in game-play between the two is
    not noticeable to the amateur gamer. 3D Online games have
    also been around for some time in the past, and have seen an huge growth in popularity in all
    the adventure and action games available there.Virtually all genres of games is available on the major websites, including
    first-person shooters, airplane missions as well as zombies, aliens, space,
    stars, racing, cooking, fashion, design, etc. As they say, you
    name it, the site will have it. Casino games and card games are rivals to be the most popular in the realm of fascination and variety, and the number of titles
    available would take some time to write here, should we even attempt.
    It is important to pick among the games that you’re the most passionate about.
    The enjoyment is worth the extra effort spent in choosing
    the appropriate game instead of choosing a random game.

    Personal preferences are the only thing that are important when playing
    online and the rest is offered by the developers who have
    left no stone unturned in bringing you a wealth of games that are free for any category.
    It’s nearly impossible finding something which fits your interests and preferences.

  26. K8

    For most up-to-date information you have
    to pay a quick visit internet and on the web
    I found this web site as a finest site for most recent updates.

  27. online slots

    Thank you for sharing your info. I truly appreciate your efforts
    and I will be waiting for your next write ups thank you
    once again.

Leave a Reply

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