How to create simple table? [html table]

If you want to make plain table, you must use html tags as below:
<table>
    <thead>
        <tr>
            <th>Employee</th>
            <th>Salary</th>
            <th>Bonus</th>
            <th>Supervisor</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td>Stephen C. Cox</td>
            <td>$300</td>
            <td>$50</td>
            <td>Bob</td>
        </tr>
        <tr>
            <td>Josephin Tan</td>
            <td>$150</td>
            <td>-</td>
            <td>Annie</td>
        </tr>
        <tr>
            <td>Joyce Ming</td>
            <td>$200</td>
            <td>$35</td>
            <td>Andy</td>
        </tr>
        <tr>
            <td>James A. Pentel</td>
            <td>$175</td>
            <td>$25</td>
            <td>Annie</td>
        </tr>
    </tbody>
</table>
or:
<table>
    <thead>
        <tr>
            <th class="clear"></th>
            <th>Salary</th>
            <th>Bonus</th>
            <th>Supervisor</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <th>Stephen C. Cox</th>
            <td>$300</td>
            <td>$50</td>
            <td>Bob</td>
        </tr>
        <tr>
            <th>Josephin Tan</th>
            <td>$150</td>
            <td>-</td>
            <td>Annie</td>
        </tr>
        <tr>
            <th>Joyce Ming</th>
            <td>$200</td>
            <td>$35</td>
            <td>Andy</td>
        </tr>
        <tr>
            <th>James A. Pentel</th>
            <td>$175</td>
            <td>$25</td>
            <td>Annie</td>
        </tr>
    </tbody>
</table>
Of course you can create them your own way but this is how we made them on our demo website.

Comments

  • On this topic of Tables can you tell me if there are color settings for the text color  and hover state background/text?

  • I'm trying to make this table:

    <table width="400px" border="1" cellspacing="0" cellpadding="5">
      <tr>
        <td align="center" valign="middle"><font face="Arial, Helvetica, sans-serif"><strong>Date Money Received</strong></font></td>
        <td align="center" valign="middle"><font face="Arial, Helvetica, sans-serif"><strong>Date Lesson Received</strong></font></td>
        <td align="center" valign="middle"><font face="Arial, Helvetica, sans-serif"><strong>Length of Lesson</strong></font></td>
        <td align="center" valign="middle"><font face="Arial, Helvetica, sans-serif"><strong>Lesson Given By</strong></font></td>
      </tr>
      <tr>
        <td align="center" valign="middle" bgcolor="#CCCCCC">&nbsp;</td>
        <td align="center" valign="middle" bgcolor="#CCCCCC">&nbsp;</td>
        <td align="center" valign="middle" bgcolor="#CCCCCC">&nbsp;</td>
        <td align="center" valign="middle" bgcolor="#CCCCCC">&nbsp;</td>
      </tr>
      <tr>
        <td align="center" valign="middle" bgcolor="#CCCCCC">&nbsp;</td>
        <td align="center" valign="middle" bgcolor="#CCCCCC">&nbsp;</td>
        <td align="center" valign="middle" bgcolor="#CCCCCC">&nbsp;</td>
        <td align="center" valign="middle" bgcolor="#CCCCCC">&nbsp;</td>
      </tr>
      <tr>
        <td align="center" valign="middle" bgcolor="#CCCCCC">&nbsp;</td>
        <td align="center" valign="middle" bgcolor="#CCCCCC">&nbsp;</td>
        <td align="center" valign="middle" bgcolor="#CCCCCC">&nbsp;</td>
        <td align="center" valign="middle" bgcolor="#CCCCCC">&nbsp;</td>
      </tr>
      <tr>
        <td align="center" valign="middle" bgcolor="#CCCCCC">&nbsp;</td>
        <td align="center" valign="middle" bgcolor="#CCCCCC">&nbsp;</td>
        <td align="center" valign="middle" bgcolor="#CCCCCC">&nbsp;</td>
        <td align="center" valign="middle" bgcolor="#CCCCCC">&nbsp;</td>
      </tr>
    </table>

    But the background color for each row alternates. How can I turn off the code so that I chose what color the background of each cell should be?
  • Sorry that's a terrible example of what I want cause I want each row a different color.
  • @hunt1151 If you want rows different color, you need to replace current #CCCCCC color in each row with a different one.
  • Ok, yes I know that. But my problem, is that regardless of what color my background is there's a code that over writes everything and the table I built has alternating row colors. 

    This is what I mean:

    As you can see the outcome is not the code that I entered in.
  • Sorry but we already realized that the code you pasted above is outdated. We have no ide where from you get such prehistoric html but this is not how current html and css works. Instead of above td code, you supposed to use something like below:
    <td style="text-align: center; background-color: #000;">Text</td>
Sign In or Register to comment.
This website uses cookies

We use cookies to personalise content and ads, to provide social media features and to analyse our traffic. We also share information about your use of our site with our social media, advertising and analytics partners who may combine it with other information that you’ve provided to them or that they’ve collected from your use of their services.

Cookies are small text files that can be used by websites to make a user's experience more efficient.

The law states that we can store cookies on your device if they are strictly necessary for the operation of this site. For all other types of cookies we need your permission. This means that cookies which are categorized as necessary, are processed based on GDPR Art. 6 (1) (f). All other cookies, meaning those from the categories preferences and marketing, are processed based on GDPR Art. 6 (1) (a) GDPR.

This site uses different types of cookies. Some cookies are placed by third party services that appear on our pages.

You can at any time change or withdraw your consent from the Cookie Declaration on our website.

Learn more about who we are, how you can contact us and how we process personal data in our Privacy Policy.

Please state your consent ID and date when you contact us regarding your consent.