How come this error comes up for one code but not the other and how do you fix it?

This error comes up only for the first code, but not the second, how come?

 Warning: A table row was 1 columns wide, which is less than the column count established by the first row (3).

        From line 1234, column 14; to line 1235, column 11

             </td>↩      </tr>↩    <

Table https://validator.w3.org/nu/
https://jsfiddle.net/weLyog5t/3/1
http://tabletest245.blogspot.com/1
----------------------------------------------

Non-table [Document checking completed. No errors or warnings to show.]
https://jsfiddle.net/a1gspkak/4/1
http://nontabletest.blogspot.com/
-----------------------------------------

The line number given is where the error was discovered, but the error itself is in line 1265. It looks like the <td> before the one starting on line 1266 does not have a closing </td> tag.

It would really help you to see these missing tags if you indented your code properly.

1 Like

I don’t know what I just changed, but it was towards the bottom of the code and now the error isn’t coming up again. https://jsfiddle.net/tjxqoomp/18/

It’s because you now have matching <td> and </td> tags. Have you run your code through the html validator yet to see if there are any other errors?

Your last table row only has one table cell, and the other ones have three. Each row in a table must have the same number of cells. If not, you need to add colspan = 3 to the cell in that last row to show that you want the cell to span three columns.

How do I fix this? https://jsfiddle.net/tjxqoomp/18/
Warning: A table row was 1 columns wide, which is less than the column count established by the first row (3).

From line 1234, column 14; to line 1235, column 11

     </td>↩      </tr>↩</tab

I don’t think that’s an error though if I wanted the last block to drop bellow. Am I right?

It IS an error - with tables all rows have the same number of columns.

That your data doesn’t is one of hundreds of indications that the data you are trying to markup with HTML is NOT a table.

1 Like

I purposely made the last row only one block element, what’s wrong with that?

IF you had an html table that contained TABULAR data (e.g. dates and temperatures, etc), and you wanted the last row to only have one cell, you would mark it up like this:

<tr>
    <td colspan = 3>
       Some content here
    </td>
</tr>

But as yours does not contain tabular data, you should really find a different solution.

2 Likes

to indicate that all the columns in that row share the same value.

Then you know that value belongs equally to all the column headings you put at the top of the table in the <thead> part of the rable.

1 Like

I just want to keep it 1 until I decide to add on to it.

Well why don’t you spend some time to actually learn HTML and then you will know how to write the correct HTML to mark up your content. That will then make styling it much easier.

To me your content looks like a list so it should probably be marked up that way.

1 Like

I did that here and it messed everything up at the bottom. https://jsfiddle.net/weLyog5t/5/

Yo, asasass.

@WebMachine and @felgall have both provided correct answers.

Here is my try :slight_smile:

A table is constructed like a checkerboard matrix or a spreadsheet in that each row must have the name number of columns (cells). One cannot have a different number of cells in different rows except in an HTML table with the use of the colspan attribute. The function of the colspan attribute is to tell the table that more than 1 column is being used for one cell; so in the end, an equal number of columns per row is accounted for.

Your MUST include two more empty cells in the last row of the HTML so there will be three cells per row.

You probably do not want those empty cells to have blue borders. OK. Because you are assigning the borders by using a className, just create two empty cells <td></td> and do not give them a className.

HTML

    <tr>
        <td class="three">
            <h3>101.ru: Swing</h3>
            <a href="http://91.223.18.205:8000/c13_4" target="_blank"></a>
        </td>
        <td></td>
        <td></td>
    </tr>
</table>

PS: this “same number of cells per row” requirement applies to non-html tables, too, even if the validator gives it a pass.

Structural integrity is the name of the game. :wink:

BTW: I concur with @WebMachine that code is much easier for humans and cats to read if it is uniformly indented. Help us help you by making your code as readable as reasonable.

Cheers.

1 Like

Someone on Stack Overflow showed me how to do it like this.
http://stackoverflow.com/a/38066642/6499132

Yours looks different than this way, which way is right?

<tr>
    <td class="two">
      <h3>
            101.ru: Swing 
          </h3>
      <a href='http://91.223.18.205:8000/c13_4' target='_blank'>
      </a>
    </td>
    <td class="three" colspan="2"></td>
  </tr>
</table>

Either can be right depending on what the actual data means. For your particular data neither is right as your data doesn’t belong in a table at all.

Both are right. Your choice.

Use whichever you understand, will remember, and will be able to apply elsewhere in a similar situation.

1 Like

ok. thanks.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.