Should Tables be avoided in HTML at any cost?

后端 未结 27 2407
生来不讨喜
生来不讨喜 2020-12-01 01:56

It is advisable to use tables in HTML pages (now that we have CSS)?

What are the applications of tables? What features/abilities does tables have that are not in CSS?

27条回答
  •  时光取名叫无心
    2020-12-01 02:28

    I think you might be slightly confused. CSS is a method of styling HTML documents, whether this is a table element or a 'div'.

    It used to be that tables were used in HTML to design the whole page layout. It was common to see multiple nested tables (usually generated by WYSIWYG programs such as Dreamweaver), and this lead to a maintainance nightmare.

    Since the introduction and adoption of CSS stylesheets it is now correct only to use a table for tabular data. That means if your data is most naturally rendered as a table use the table element. You can still style the table using CSS.

    However, and I generally disapprove of this method since it duplicates existing functionality, it is possible to use elements to build a table like structure. In fact there are several website that will generate such code for you, but I have no links to hand.

    Remeber also that some users might be either viewing in text only mode, or using a screen reader both of which will probably break the page (like reading the columns vertically rather than horizontally) hence the proper use of tables.

    HTH

提交回复
热议问题