Is it semantically correct to have an action button column in an html table?

冷暖自知 提交于 2019-12-10 18:20:08

问题


Say you have some tabular data you want to display, as well as allow the user to perform some action on a row.

Is that semantically correct to have an "action" column? (could be "edit", "vote", or whatever)

If so should the action text be in the header cell with an icon in the actual column, or should that text be repeated on each cell (in the form of a button or link) and the header cell blank?


回答1:


I think this would be fine.

If the action directly relates to the table and the table contains tabular data, then this would be fine.

I would put a description of the action in the head and then place an icon or a button in the cells.

In order to make sure the table can be used as widely as possible, make sure

  1. it retains its tab structure
  2. the columns and rows are plainly marked
  3. the buttons are given names, values or alt tags.

Also, I would say remember that semantic markup is not the goal... it is only a tool to achieve the best possible product. In some cases, semantics may need to be subjugated to need.



来源:https://stackoverflow.com/questions/7373692/is-it-semantically-correct-to-have-an-action-button-column-in-an-html-table

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!