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,564 comments

  1. porn cam sites

    All the more reason to show her you care. Around midnight, still awake, I remembered
    something I forgot to take care of, went downstairs and took care of it.
    This week alone, the former wife of cheating TV sports presenter
    Richard Keys went to the police to complain about a disobliging Tweet from his sister, who claimed she was lying in a book she has written about Keys’ infidelity with his daughter’s best friend.
    I’m not sure if your wife is going to be happy with your decision, but
    who cares what that bitch wants anyway, right? For those who really wanna enhance their sex experience by taking it up a notch
    to the next level – you can really get involved by broadcasting yourself!
    No matter what you wanna see, there is always
    someone here waiting for you! See, I’m a professional, when it comes to finding the best, famous, and most popular
    places on the internet for (free) live cam sex.

  2. online bets

    This will not occur with the quick payout betting websites
    that we suggest.

  3. bet on sports

    Fanduel is a exceptional platform known for its ease of use and coverage of live sports.

  4. online betting

    If punters wish to make their virtual betting
    even extra fruitful, they can generally use the bountiful
    promotions of the bookmaker.

  5. how sports betting works

    And when New York does authorize mobile sports betting, other large players will target the
    state.

  6. pubic hair

    VSiN, The Sports Betting Network, has you covered with this list of terms
    to increase your betting IQ.

  7. sports betting agencies

    It was established in 2014 in Costa Rica and is quickly growing
    to compete with other older bet staking web pages.

  8. sports betting the best

    Unquestionably, these bonuses and our commitment to making a comfortable
    betting environment is what sets BetNow apart from the competitors.

  9. hair removal

    They have the biggest quantity of football matches to bet on from not only European leagues but also South America, Africa, Asia and even India.

  10. Jocosa CBD Gummies

    This is a very good tip especially to those fresh to the blogosphere.
    Brief but very accurate information? Thanks for
    sharing this one. A must read post!

    My site :: Jocosa CBD Gummies

  11. playing online casino

    The NCAA instituted a de facto ban on national championship contests being held in states with legal sports betting, namely Nevada.

  12. online sports books

    Depending on the perceived talent gap, among the sides involved, straight up odds can range from +one hundred to upwards of +/ or a lot more.

  13. 스포츠토토추천

    Kindred’s key revenue comes from casino games and on line sports
    betting.

  14. Dario

    Link exchange is nothing else except it is just placing the other
    person’s webpage link on your page at proper place and other
    person will also do similar in support of you.

    My web site … خرید رپورتاژ آگهی (Dario)

  15. online webcam sex chat

    The practice of self-restraint, mental strength, genuineness, compassion and selflessness add
    up to the practice of Yoga. These costs add up, according to The National Campaign to Prevent Teen and Unplanned Pregnancy, which estimates that teen childbearing
    costs taxpayers at least $10.9 billion annually.
    Thirst can also masquerade as hunger – so if you’re looking to stay
    healthy and keep your waist line in check I’d recommend at
    least 8-10 glasses a day. Help, check out my hub Fattie Females.
    Example: An example of appropriate educational use would be a teacher who is using clip art to illustrate worksheets she is handing out
    to her students. Besides, most of my friends are foreigners while Japanese friends
    are people who studied abroad, who studied foreign language, who travel around the world,
    therefore they are quite open-minded and eager to meet foreigners.
    Characteristic of this kind of narcissism is the viewing
    of other human beings not as whole people who have their own feelings,
    wants and needs, but rather as deliverers of desperately needed satisfaction that shores up a fragile sense of self.

  16. online sports betting-

    Not all of those state legislatures adopted the exact same method, resulting in various laws and suggestions.

  17. Full Body Pills

    Super-Duper website! I am loving it!! Will be back later to read some more.
    I am bookmarking your feeds also

    Here is my web site; Full Body Pills

  18. find love online

    Their pass rush is an abomination but Derrick Henry is the very best operating back in the league.

  19. online sports books

    Mississippi, West Virginia, New Mexico, Pennsylvania, and Rhode Island which have
    legalized sports betting in some kind as of Dec.
    2018.

  20. sports betting strategies

    They changed their name from VC Bet to BetVictor and the new on the internet
    betting web site was founded.

  21. free online sex cams

    The person doing the modeling can also map different textures into their photo to give it an even more real feel.
    Besides being able to significantly increase the size of your penis, doing exercises regularly
    will ensure you of a far more healthier and sexually fitter manhood within a few short weeks from now, which would keep your woman (or any, for that
    matter) satisfied in bed for years to come! This article Orgone Energy, Wilhelm Reich And The Threat
    To The Men In Power will describe how this little known scientist, psychoanalyst
    and inventor was on the cusp of taking mankind to the next level of
    social, economic and spiritual evolution only to be silence by The
    Powers That Be. Teen hardcore vidseos and Young Tiny Girls
    Stickam are totally the best sex movies to watch, Do
    you want to see cute little naked girls in front of the web camera getting fucked by their older boyfriends?
    Educational techniques for ADHD – What are executive function skills?

  22. arbitrage sports betting

    BookMaker enables you to place your bets on these sports,
    all element of their in depth list of betting markets.

  23. online offers

    Aѕ a matter оf fact itѕ just аbоut imроѕѕiblе,mаthеmаtiсаllу ѕреаking.

  24. sports betting online

    Downtown’s PHX Arena is also residence to the WNBA’s Phoenix Mercury and the Indoor
    Football League’s Arizona Rattlers.

  25. CamHandy Review

    I intended to put you a very small remark in order to give many thanks
    yet again considering the beautiful concepts you have provided in this case.
    It is surprisingly open-handed with you in giving openly exactly what most of
    us might have sold for an e-book to generate some bucks for themselves, chiefly considering the fact that you could possibly have done
    it in case you decided. Those points likewise acted to
    become a fantastic way to comprehend other individuals
    have a similar zeal just as my own to learn a lot more in terms of this condition. Certainly there are millions of more pleasant opportunities
    up front for folks who read your site.

    Here is my blog … CamHandy Review

Leave a Reply

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