html table.rows,html table - by rows or columns

问题

do all browsers support html table by columns first.

i know you can do:

but can you build up a table by columns first? Is there anything wrong with doing cols first?

回答1:

That is not how the HTML standard is. You make your table, then you make a row, and then your columns. There is some additional stuff for headers, bodies, etc. But the standard (and only supported method) is by row and not by column.

回答2:

According to the W3C HTML4 Table Specifications:

Furthermore, authors may

declare column properties at the start

of a table definition (via the

COLGROUP and COL elements) in a way

that enables user agents to render the

table incrementally rather than having

to wait for all the table data to

arrive before rendering.

This important note on column properties does not change the functional structure of the table but does allow for flexibility in both styling a table as well as semantically describing its data. Specifically, associated row and column data provides benefits to screenreaders.

That stated your table is still structured by row and then column. The colgroup and col elements are used prior to the actual table structure appearing before thead.

回答3:

You need to think in terms of a relational DOM (Document Object Model).

Table -- Parent

TR --- Child

TD ---- Child

Its true tables do have a cells collection, but cells can never be direct decedents of a table. a cell must be encompassed in a row, and a row must be a child of a table element.

If you're looking for another approach, try using XHTML, you can nest divs and spans to replace tables. But I personally prefer good old HTML 4.

回答4:

HTML tables have tbody (and thead and tfoot) elements which contain table row elements which contain table data cell and table header cell elements.

You can't build a table by providing a each full column in turn. Only each full row in turn.

回答5:

Well you should really used HTML standard, the reasons is because messing with a tables columns and rows can make the code tricky to deal with. Just stick with standard HTML.

回答6:

To print columns first, do it as a table:

's in tables within a table.

See the following example:

// begin parent table here: tr and td

//first row (in a sense) of cols
//first row (in a sense) of cols
//first row (in a sense) of cols

// end parent td start new td

//second row (in a sense) of cols
//second row (in a sense) of cols
//second row (in a sense) of cols

// end parent td and tr and end table

来源:https://stackoverflow.com/questions/1285456/html-table-by-rows-or-columns

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值