2
<table border="1">
    <tbody>
        <tr>
            <td>1</td>
            <td>2</td>
        </tr>
        <tr>
            <td>3</td>
            <td>4</td>
        </tr>
    </tbody>
</table>

If I write this, the browser will analyze normally.

<!-- <table border="1"> -->
    <tbody>
        <tr>
            <td>1</td>
            <td>2</td>
        </tr>
        <tr>
            <td>3</td>
            <td>4</td>
        </tr>
    </tbody>
<!-- </table> -->

But I write like this, I find the browser will analyze them without any tags like string.

<tbody>
    <tr>
        <td>1</td>
        <td>2</td>
    </tr>
    <tr>
        <td>3</td>
        <td>4</td>
    </tr>
</tbody>

is the same of

1 2 3 4
Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
qiuyuntao
  • 2,314
  • 4
  • 19
  • 24

1 Answers1

7

Browsers ignore the <tbody>, <tr>, and <td> tags and the corresponding end tags. This has not been specified in HTML specifications, since they do not define the parsing of syntactically erroneous documents. In the HTML5 draft, however, there is a description that defines the browser behavior in a manner that corresponds to the what browsers actually do: Tree construction.

This means that you cannot write an HTML document that contains, say, a <tr> element outside a table element. The HTML parser in a browser simply does not construct such document trees. (You can, however, construct such a document dynamically with client-side scription.)

Jukka K. Korpela
  • 195,524
  • 37
  • 270
  • 390