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.