就目前而言,这个问题不适合我们的问答形式。我们希望答案得到事实、引用或专业知识的支持,但这个问题可能会引起辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the help center为指导。
9年前关闭。
锁定。这个问题及其答案是locked因为这个问题是题外话,但具有历史意义。它目前不接受新的答案或互动。
好像是general opinion表格不应该用于 HTML 中的布局。
为什么?
我从来没有(或说实话很少)看到这方面的好论据。通常的答案是:
最佳答案
我将一个接一个地审查你的论点,并试图指出其中的错误。
It's good to separate content from layout But this is a fallacious argument; Cliché Thinking.
<table>
的论据。今天的元素,明天可能会有,因为浏览器供应商对元素应用特殊处理的方式。毕竟,他们知道“<table>
元素仅用于表格数据”,并且可能会利用这一事实来改进渲染引擎,在此过程中巧妙地改变了 <table>
s 的行为,从而打破了以前被滥用的情况。So what? Does my boss care? Do my users care?
Perhaps me or my fellow developers who have to maintain a web page care... Is a table less maintainable? I think using a table is easier than using divs and css.
By the way... why is using a div or a span good separation of content from layout and a table not? Getting a good layout with only divs often requires a lot of nested divs.
<div>
s 是一种反模式,就像表格布局一样。优秀的网页设计师不需要很多。另一方面,即使是这种嵌套很深的 div 也不会有很多表格布局的问题。事实上,它们甚至可以通过逻辑地将内容分成几部分来形成语义结构。Readability of the code I think it's the other way around. Most people understand html, little understand css. It's simpler.
It's better for SEO not to use tables
Tables are slower. An extra tbody element has to be inserted. This is peanuts for modern web browsers.
Show me some benchmarks where the use of a table significantly slows down a page.
Most web sites that need an upgrade need new content (html) as well. Scenarios where a new version of a web site only needs a new css file are not very likely.
https://stackoverflow.com/questions/83073/