简体   繁体   English

是“ <tr><th/><td/></tr> 合法的HTML代码段?

[英]Is “<tr><th/><td/></tr>” a legal HTML snippet?

I have a HTML code snippet: 我有一个HTML代码段:

<table>
 <tr>
  <th>a header</th>
  <td>some content</td>
 </tr>
</table>

the rendering is as it would be a table with two columns. 渲染就像是一张有两列的表格。 Is it a legal HTML code? 它是合法的HTML代码吗?

For which version of HTML? 哪个版本的HTML? The W3C validator is pretty definitive: W3C验证器非常确定:

http://validator.w3.org/check http://validator.w3.org/check

It validates ok as HTML 4.01 transitional. 它将确定为HTML 4.01过渡版本。

HTML 的 CSS 属性<div id="text_translate"><p> So i've watched a lecture on CSS rules inheritance and I was curious about how it would hork with HTML tables, so i tried to test some code to get a better understanding of inheritance.</p><p> 我写了以下代码: </p><p></p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"><div class="snippet-code"><pre class="snippet-code-css lang-css prettyprint-override"> table{ border: 1px solid black; color: greenyellow; }.Table2, .th2{ border: 1px solid black; color: greenyellow; }</pre><pre class="snippet-code-html lang-html prettyprint-override"> &lt;,DOCTYPE html&gt; &lt;hmt lan="en"&gt; &lt;head&gt;&lt;/head&gt; &lt;body&gt; &lt;table class="Table"&gt; &lt;tr&gt; &lt;th&gt; Style &lt;/th&gt; &lt;th&gt; ID &lt;/th&gt; &lt;th&gt; # of Classes, Pseudo-Classes &lt;/th&gt; &lt;th&gt; # of Elementes &lt;/th&gt; &lt;/tr&gt; &lt;/table&gt; &lt;br&gt;&lt;br&gt; &lt;table class="Table2"&gt; &lt;tr&gt; &lt;th class="th2"&gt; Style &lt;/th&gt; &lt;th class="th2"&gt; ID &lt;/th&gt; &lt;th class="th2"&gt; # of Classes, Pseudo-Classes &lt;/th&gt; &lt;th class="th2"&gt; # of Elements &lt;/th&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/body&gt; &lt;/html&gt;</pre></div></div><p></p><p> 我希望两个 CSS 代码看起来相同,因为 &lt;th&gt; 标签似乎是 &lt;table&gt; 标签的子标签。 事实上,使用第一个 CSS 规则,Color 属性确实从 &lt;table&gt; 继承到 &lt;th&gt;,并且 &lt;th&gt; 中定义的文本是绿色的,但边框属性似乎没有被继承。 在第一种情况下,我只是在桌子周围得到一个正方形,在第二种情况下,我得到相同的正方形,但每个句子周围都有小正方形。</p><p> <a href="https://i.stack.imgur.com/mGtTI.png" rel="nofollow noreferrer">从第一个 CSS 规则到 &lt;table&gt; 的结果</a></p><p><a href="https://i.stack.imgur.com/X71tp.png" rel="nofollow noreferrer">第二个 CSS 规则的结果到 &lt;table&gt; &lt;th&gt;</a></p><p> 现在我的问题是:为什么 &lt;th&gt; 在第一种情况下没有继承边框属性,是否有一些属性不会从父级传递给子级,如果是,我在哪里可以找到它们? 或者也许 &lt;th&gt; 被定义为不是 &lt;table&gt; 孩子? 这里发生了什么?</p></div>继承到<table> <tbody><tr><td> ,</td><th> ,</th></tr><tr></tr></tbody></table> - Which CSS properties for an HTML <table> inherit to <td>, <th>, <tr>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 BeautifulSoup HTML提取表格数据; 环 <tr><th><td> - BeautifulSoup HTML extracting tabular data; loop <tr> <th> <td> HTML 的 CSS 属性<div id="text_translate"><p> So i've watched a lecture on CSS rules inheritance and I was curious about how it would hork with HTML tables, so i tried to test some code to get a better understanding of inheritance.</p><p> 我写了以下代码: </p><p></p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"><div class="snippet-code"><pre class="snippet-code-css lang-css prettyprint-override"> table{ border: 1px solid black; color: greenyellow; }.Table2, .th2{ border: 1px solid black; color: greenyellow; }</pre><pre class="snippet-code-html lang-html prettyprint-override"> &lt;,DOCTYPE html&gt; &lt;hmt lan="en"&gt; &lt;head&gt;&lt;/head&gt; &lt;body&gt; &lt;table class="Table"&gt; &lt;tr&gt; &lt;th&gt; Style &lt;/th&gt; &lt;th&gt; ID &lt;/th&gt; &lt;th&gt; # of Classes, Pseudo-Classes &lt;/th&gt; &lt;th&gt; # of Elementes &lt;/th&gt; &lt;/tr&gt; &lt;/table&gt; &lt;br&gt;&lt;br&gt; &lt;table class="Table2"&gt; &lt;tr&gt; &lt;th class="th2"&gt; Style &lt;/th&gt; &lt;th class="th2"&gt; ID &lt;/th&gt; &lt;th class="th2"&gt; # of Classes, Pseudo-Classes &lt;/th&gt; &lt;th class="th2"&gt; # of Elements &lt;/th&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/body&gt; &lt;/html&gt;</pre></div></div><p></p><p> 我希望两个 CSS 代码看起来相同,因为 &lt;th&gt; 标签似乎是 &lt;table&gt; 标签的子标签。 事实上,使用第一个 CSS 规则,Color 属性确实从 &lt;table&gt; 继承到 &lt;th&gt;,并且 &lt;th&gt; 中定义的文本是绿色的,但边框属性似乎没有被继承。 在第一种情况下,我只是在桌子周围得到一个正方形,在第二种情况下,我得到相同的正方形,但每个句子周围都有小正方形。</p><p> <a href="https://i.stack.imgur.com/mGtTI.png" rel="nofollow noreferrer">从第一个 CSS 规则到 &lt;table&gt; 的结果</a></p><p><a href="https://i.stack.imgur.com/X71tp.png" rel="nofollow noreferrer">第二个 CSS 规则的结果到 &lt;table&gt; &lt;th&gt;</a></p><p> 现在我的问题是:为什么 &lt;th&gt; 在第一种情况下没有继承边框属性,是否有一些属性不会从父级传递给子级,如果是,我在哪里可以找到它们? 或者也许 &lt;th&gt; 被定义为不是 &lt;table&gt; 孩子? 这里发生了什么?</p></div>继承到<table> <tbody><tr><td> ,</td><th> ,</th></tr><tr></tr></tbody></table> - Which CSS properties for an HTML <table> inherit to <td>, <th>, <tr> 基于tr计数的td / th的XPath - XPath for td/th based on tr count 无法创建 DocumentFragment 存储 td、tr 或 th? - Cannot create DocumentFragment storing td, tr or th? td 中的 Html 表 tr - Html table tr inside td 通过简单的dom解析器在html表中循环并获取php中的tr,th和td - loop through html table and get tr, th and td in php with simple dom parser 如何解析包含两者的行的 HTML 表<th>和<td>标签下的<tr>标签? - How to parse HTML table with rows contaning both <th> and <td> tags under the <tr> tag? html + css表 - tr的border-bottom重叠td / th的border-right - html+css tables - border-bottom of tr overlaps border-right of td/th 动态添加td和tr onLlick HTML JQUERY - Dynamically add td and tr onclick HTML JQUERY 获取最近的tr html(不包括最后的td) - Get Closest tr html excluding last td
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM