Why is not allowed inside

后端 未结 2 1077
渐次进展
渐次进展 2020-12-18 20:30

Why can\'t

be nested inside

? What is the correction I could make? Removing the
and

相关标签:
2条回答
  • 2020-12-18 21:01

    In answer to your actual question a paragraph cannot contain any other block elements, which includes tables. Also in addition to this the closing </p> tag is optional so the first closing tag that is subsequently found by the parser will deem to have closed the paragraph.

    It would help if I could see more of the code and layout, however I believe that removing the <p> tags from around the tables and then correctly formatting the positioning of your tables using CSS should achieve your results.

    <div class="right_articles">
                <table>
                <tr>
                <td>
                    <img alt="Img not found" src="images/ribbon.gif"                     
                        style="width: 155px; height: 125px;" />
                </td>
                <td>
                    <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label><br />
                    <asp:Label ID="Label2" runat="server" Text="Label"></asp:Label><br />
                    <asp:Label ID="Label3" runat="server" Text="Label"></asp:Label>
                </td>
                </tr>
                </table>
                <p>&nbsp;</p>
                <table>
                <tr>
                <td>
                    <img alt="Img not found" src="images/medal.gif"                     
                        style="width: 155px; height: 125px;" />
                </td>
                <td>          
                    <asp:Label ID="Label4" runat="server" Text="Label"></asp:Label><br />
                    <asp:Label ID="Label5" runat="server" Text="Label"></asp:Label><br />
                    <asp:Label ID="Label6" runat="server" Text="Label"></asp:Label>      
                </td>
                </tr>
                </table>
            </div>
    
    0 讨论(0)
  • 2020-12-18 21:07

    In HTML it's important to understand that P elements cannot contain other block level elements and TABLE is a block level element. The P closing tag is optional and when you try to make a P element contain something that it cannot contain, the closing P tag is assumed by the browser.

    The P element represents a paragraph. It cannot contain block-level elements (including P itself).

    http://www.w3.org/TR/html401/struct/text.html#h-9.3.1

    0 讨论(0)
提交回复
热议问题