What is the point of Grid?


#1

It behaves very similar to a Table, if a little bit more customizable. It tells the browser to display elements in a series of rows and columns. This is a matter of structure, yes? If it’s a structural thing, wouldn’t the best practice be to handle it in the HTML file as a Table?

My question is this: if the Table element in HTML and the Grid element in CSS accomplish a very similar task with a similar purpose, isn’t one of them an improper abstraction? Structure belongs in HTML, and style belongs in CSS, so if Table and Grid are both for the same purpose, be it a matter of structure or style, one of them is in the wrong place, right?


#2

Table certainly has its usage, but grid does bring something extra features:

https://medium.com/@js_tut/new-things-css-grid-brings-to-the-table-e465cb5d2841
http://jensimmons.com/ -> design with grid video

both grid and table have there usages.


#3

I understand that both have their usages. My question isn’t about their usefulness at all. My question is how can we reconcile the idea that “We should put structure in HTML, and style in CSS” with the fact that we have two similar tools that accomplish something quite like each other, one in HTML and one in CSS?


#4

a <table> without css could achieve very little. And a css grid won’t work without html code. Html and css are so tightly weaved together.

i will do you one better, there is even display: table for css

in programming, there are often a dozen different ways to do something, which has advantages (you can make something perfect (or close to) but you have to choice the right option. Everything has pros and cons, so its your roll to judge.


#5

That still doesn’t answer my question. It helps out a lot if I’m confused as to which one is more useful, but I’m not. They’re both tools, and they’re both useful, and I’ve got a pretty good grasp about when to use each.

What I’m confused about is an ideological question. Early on in HTML and CSS we learn the ideology that HTML is for structure and CSS is for style, and that we shouldn’t mix the two. Because the natures of Grid and Table are so similar I have trouble reconciling them with that ideology.

If arranging things in rows and columns is a matter of structure, then how can we say both “structure should stay out of CSS” and “we have a CSS tool that arranges things in rows and columns.”?
Likewise, if arranging things in rows and columns is a matter of style, then how can we both say “style should stay out of HTML” and “we have an HTML tool that arranges things in rows and columns.”?

One of those two tools must be counter to the narrative of separation of style and structure, right?


#6

i disagree with this statement, css is not only for style, its also for positioning.

and both are within the ideology, both (table and grid) have a html structure and css styling and positioning.


#7

After a little more reading, you’re right. Positioning is definitely a design/display concept, and definitely falls under CSS. As for Table, it’s still useful for structurally abstracting data into individual cells, but definitely shouldn’t be used to try and control how they display on-page.

I guess I was looking at it from the wrong perspective.


#8

so, all good now?


#9

Wonderful. Thank you for taking the time to explain things for me.