Why is the Bootstrap grid layout preferable to an HTML table?

后端 未结 9 891
生来不讨喜
生来不讨喜 2021-01-31 01:30

[Note: for those who may be confusing this question with \"why not use tables for HTML layout\", I am not asking that question. The question I\'m asking is why is a grid layout

9条回答
  •  青春惊慌失措
    2021-01-31 02:25

    The difference is that the first example is semantically marked up, assuming the data being marked up is not actually tabular.

    should only be used for tabular data, not for any data which happens to be displayed in a layout similar to a table.

    It is correct though that using CSS packages like Bootstrap, which require you to assign classes to HTML elements which are not semantic but presentational, reduces the separation of content and presentation, making the difference somewhat moot. You should be assigning semantically meaningful classes to your elements and use lesscss mixins (or similar technology) to assign presentational behavior defined in the CSS framework to these classes, instead of assigning the presentational classes to the elements directly.

    Say:

    .products { .row; } .products > .product { .span16; }

    Note that I say should. In practice this is not necessarily always the more workable option, but it should be the theoretical goal.

    提交回复
    热议问题