0

I am creating a table and this table has 4 rows and two columns, when the second row has more words, the current column scales forward leaving the other rows with spaces.

I left the code here:

<table border="1">
<tr><td>name<td><td>cat</td></tr>
<tr><td>pneumonoultramicroscopicsilicovolcanoconiosis<td><td>vulcano</td></tr>
<tr><td>age<td><td>2 years</td></tr>
<tr><td>sex<td><td>male</td></tr>
</table>

I wanted each row to remain with its column intact, for example:

[name: | cat]

[pneumonoultramicroscopicsilicovolcanoconiosis: | vulcano]

[age: | 2 years]

[sex: | male]

The code is leaving like this:

[name:                                          | cat]

[pneumonoultramicroscopicsilicovolcanoconiosis: | vulcano]

[age:                                           | 2 years]

[sex:                                           | male]

How can I solve this?

sYsTeM
  • 37
  • 3
  • 18

2 Answers2

1

There is a similar question here: html table cell width for different rows

The sum of the answer: You can't using this method -- Table structure doesn't work that way.

You have a couple options:

  1. Put each row in it's own table:

    <table border="1">
      <tr><td>name<td><td>cat</td></tr>
    </table>
    <table border="1">
      <tr><td>pneumonoultramicroscopicsilicovolcanoconiosis<td><td>vulcano</td></tr>
    </table>
    <table border="1">
      <tr><td>age<td><td>2 years</td></tr>
    </table>
    <table border="1">
      <tr><td>sex<td><td>male</td></tr>
    </table>
    
  2. Use the div element and CSS instead of tables.

Clay
  • 64
  • 1
  • 6
0

You can close the td tag in each data Eg :namecat age2 years Like this. ^^^