为什么为&lt;表&gt;不准里面&LT; P&GT; [英] Why is <table> not allowed inside <p>
问题描述
为什么不能&LT; P&GT;
嵌套在&LT;表&gt;
?什么是我可以改正?
删除&LT; DIV&GT;
和&LT; P&GT;
标签损坏我的设计。由于网站遵循客户提供的设计。
我有以下的code和它在VS2008中工作得很好,但我得到的警告:
&LT; DIV CLASS =right_articles&GT;
&所述p为H.;
&LT;表&gt;
&所述; TR&GT;
&所述; TD&GT;
&LT; IMG ALT =图未找到SRC =图像/ ribbon.gif的风格=WIDTH:155px;高度:125px; /&GT;
&LT; / TD&GT;
&所述; TD&GT;
&LT; ASP:标签ID =Label1的=服务器文本=标签&GT;&LT; / ASP:标签&gt;&LT; BR /&GT;
&LT; ASP:标签ID =Label2的=服务器文本=标签&GT;&LT; / ASP:标签&gt;&LT; BR /&GT;
&LT; ASP:标签ID =LABEL3=服务器文本=标签&GT;&LT; / ASP:标签&gt;
&LT; / TD&GT;
&LT; / TR&GT;
&LT; /表&gt;
&所述; / P&GT;
&所述p为H.;&放大器; NBSP;&下; / P&GT;
&所述p为H.;
&LT;表&gt;
&所述; TR&GT;
&所述; TD&GT;
&LT; IMG ALT =图未找到SRC =图像/ medal.gif的风格=WIDTH:155px;高度:125px; /&GT;
&LT; / TD&GT;
&所述; TD&GT;
&LT; ASP:标签ID =Label4=服务器文本=标签&GT;&LT; / ASP:标签&gt;&LT; BR /&GT;
&LT; ASP:标签ID =Label5=服务器文本=标签&GT;&LT; / ASP:标签&gt;&LT; BR /&GT;
&LT; ASP:标签ID =Label6=服务器文本=标签&GT;&LT; / ASP:标签&gt;
&LT; / TD&GT;
&LT; / TR&GT;
&LT; /表&gt;
&所述; / P&GT;
&LT; / DIV&GT;
警告1此结束标记没有匹配的开始标记。
E:\\ WebSite4 \\ test.master 121报警2验证(XHTML 1.0
过渡性):文本是不允许开合间
为元素的HTML标记。 E:\\ WebSite4 \\ test.master 5警告3验证
(XHTML 1.0过渡):元素形式缺少结束标记。
E:\\ WebSite4 \\ test.master 21警告4类或的CssClass值
没有定义的。 E:\\ WebSite4 \\ test.master 33警告5文件spacer.gif的
没找到。 E:\\ WebSite4 \\ test.master 116警告7验证(XHTML
1.0过渡):元素IMG缺少必需属性ALT。 E:\\ WebSite4 \\ test.master 116警告8验证(XHTML 1.0
过渡):元素'表'不能嵌套元素'P'之内。
E:\\ WebSite4 \\ test.master 78警告9验证(XHTML 1.0
过渡):元素'表'不能嵌套元素'P'之内。
E:\\ WebSite4 \\ test.master 93
块引用>解决方案在HTML明白的
P
元素不能包含其他块级元素和表格是一个块级元素。在P
结束标记是可选的,当你试图让一个P
元素中包含的东西,它不能包含,闭幕P
标记是由浏览器承担。
再pre元素psents一个段落。它不能包含块级
元件(包括P个本身)。
块引用><一个href=\"http://www.w3.org/TR/html401/struct/text.html#h-9.3.1\">http://www.w3.org/TR/html401/struct/text.html#h-9.3.1
Why can't
<p>
be nested inside<table>
? What is the correction I could make? Removing the<div>
and<p>
tags corrupt my design. As the website follows a client provided design.I have the following code and it works fine in VS2008, but i get warnings:
<div class="right_articles"> <p> <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> <p> </p> <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> </p> </div>
Warning 1 This end tag has no matching start tag. E:\WebSite4\test.master 121 Warning 2 Validation (XHTML 1.0 Transitional): Text is not allowed between the opening and closing tags for element html'. E:\WebSite4\test.master 5 Warning 3 Validation (XHTML 1.0 Transitional): Element 'form' is missing its closing tag. E:\WebSite4\test.master 21 Warning 4 The class or CssClass value is not defined. E:\WebSite4\test.master 33 Warning 5 File 'spacer.gif' was not found. E:\WebSite4\test.master 116 Warning 7 Validation (XHTML 1.0 Transitional): Element 'img' is missing required attribute 'alt'. E:\WebSite4\test.master 116 Warning 8 Validation (XHTML 1.0 Transitional): Element 'table' cannot be nested within element 'p'. E:\WebSite4\test.master 78 Warning 9 Validation (XHTML 1.0 Transitional): Element 'table' cannot be nested within element 'p'. E:\WebSite4\test.master 93
解决方案In HTML it's important to understand that
P
elements cannot contain other block level elements and TABLE is a block level element. TheP
closing tag is optional and when you try to make aP
element contain something that it cannot contain, the closingP
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
这篇关于为什么为&lt;表&gt;不准里面&LT; P&GT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!