[英]HTML td will not break to new line with <!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN”>
I am having an issue with getting table cell to respond to styles as expected. 我遇到了让表格单元格按预期响应样式的问题。 Please do not recommend using div and CSS.
请不要建议使用div和CSS。 I know it is better, but not appropriate for this particular issue.
我知道它更好,但不适合这个特殊问题。 I also cannot change the doctype because it is CMS with closed source.
我也无法更改doctype,因为它是带有封闭源的CMS。 This works as expected with the XHTML doctype
这与XHTML doctype一样正常
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<style>
.foottable{
width:100%;
table-layout:fixed;
}
.foottable td{
display: block;
width: 100%;
}
</style>
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0" width="100%" class="foottable">
<tbody>
<tr valign="top">
<td>
<b>About</b>
<a href="info.html">About</a>
<a href="press.html">Press</a>
<a target="_blank" href="http://blog.com/">Blog</a>
<a href="events.html">Events</a>
<a href="stores.html">Store Locations</a>
<a href="ind.html">Site Map</a>
</td>
<td>
<b>Customer Service</b>
<a href="shipping.html">Shipping</a>
<a href="returnpolicy.html">Returns</a>
<a href="giftcert.html">Gift Certificates</a>
<a href="privacypolicy.html">Privacy Policy</a>
<a href="terms.html">Terms & Conditions</a>
</td>
</tr>
</tbody>
</table>
</body>
</html>
As soon as the doctype is HTML 4.01 it does not work as expected 只要doctype是HTML 4.01,它就无法按预期工作
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<style>
.foottable{
width:100%;
table-layout:fixed;
}
.foottable td{
display: block;
width: 100%;
}
</style>
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0" width="100%" class="foottable">
<tbody>
<tr valign="top">
<td>
<b>About</b>
<a href="info.html">About</a>
<a href="press.html">Press</a>
<a target="_blank" href="http://blog.com/">Blog</a>
<a href="events.html">Events</a>
<a href="stores.html">Store Locations</a>
<a href="ind.html">Site Map</a>
</td>
<td>
<b>Customer Service</b>
<a href="shipping.html">Shipping</a>
<a href="returnpolicy.html">Returns</a>
<a href="giftcert.html">Gift Certificates</a>
<a href="privacypolicy.html">Privacy Policy</a>
<a href="terms.html">Terms & Conditions</a>
</td>
</tr>
</tbody>
</table>
</body>
</html>
This is what I expect to see: 这是我期望看到的:
This is what I see: 这就是我所看到的:
Anyone have any insight to why the doctype does not set the td on their own line? 任何人都有任何见解为什么doctype没有在自己的行上设置td? I am using Chrome.
我正在使用Chrome。 I checked firefox and it works as expected.
我检查了Firefox,它按预期工作。
As noted above: 如上所述:
I did find the ability to enable the loose definition "w3.org/TR/html4/loose.dtd";
我确实找到了启用松散定义“w3.org/TR/html4/loose.dtd”的能力; which solved the issue.
这解决了这个问题。
References 参考
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.