The Anti-Hero of CSS Layout – “display:table” (2014)
colintoh.com
colintoh.com
I don't think people have a hard time understanding that you shouldn't use the <blockquote>-element for something which is not a quote. But html tables had a more troubled history because for a long time html tables were the only way to achieve certain layout effects, which was not supported by pure CSS in mainstream browsers, because they didn't implement "display:table".
This article is well-intentioned but I think it also contains some language which muddies a pretty simple concept. Eg. it states CSS Table has a key differentiation over HTML Table. It can choose not to be a table by just adjusting its CSS properties. Something that HTML Table is incapable of. The sentence seem to confuse semantics with presentation, which is what got us into this mess in the first place.
First to come to mind: A table with many rows displayed on a tiny mobile screen. The most common solution is to let the table overflow horizontally. There are other complex solutions, most of them fall in the CSS-Hack category.
In this case, to have a CSS table that can be something else on a tiny screen (via media queries) may lead to a successful UX solution.
In the MySQL monitor, you can terminate a statement with ; for tabular view, or with \G for a linear view that represents each row as a key-value list. This is super useful for reading wide rows in narrow terminals. I can very easily see the appeal of doing the same for wide tables on narrow displays.
It is true older browsers had partially hardcoded presentation so you couldn't always override the default CSS of certain elements (table elments and form controls were especially notorious for hardcoded presentation). But I believe this is not an issue in modern browsers.
I think the last browser that saw widespread use in any market with that issue was NN4. In some markets, Opera [some version; 7?] with the same issue will have been a problem much later than NN4. Really, this is to say: this hasn't been a concern for well over a decade at this point even with fairly generous browser support matrices.
imo, there are a lot of different paths to being a good developer. Personally I find scouring over the standards or some dry reference site to be about the most painful way.
[1] https://www.w3.org/TR/CSS2/visudet.html#Computing_widths_and...
Which is a smell to me, but I just can't help but find that every time I have consistent results and expected behaviour. Div and flexbox for everything.
It actually reminds me of another smell I have with django: write my own serializers and views rather than using any of the magical ones. I tried so hard to use the freebies but the moment you want something that isn't exactly as prescribed, it becomes a disaster. That's been my experience with CSS and HTML layouts.
I haven't tested it, but I assume you could fake the semantic part of a "CSS table" with something like `role=grid`
It's always bugged me to see the great lengths people will go to to avoid using an HTML table to create things like a calendar. A calendar is a table! Save yourself the effort and use <table>. It's not only easier, it's semantically correct as well.
The semantic definition of table in HTML is a bit more subtle - it is a set of data structured in two dimensions. (Like how the days in a monthly calendar is grouped by week (horizontally) and by day-of-week (vertically)).
it's really something that after all these years, in 2017, microsoft browsers still find a way to hold back web features.
As for K-12, is that really a requirement in some places, or is it just the case that some clients just happen to not be updated?
More generally IE9 and IE10 are both still supported by Microsoft (for Vista SP2, Server 2008 SP, Server 2008 IA64; and for Server 2012, and Embedded 8 Standard), so it seems entirely plausible Microsoft would sell security updates for other OSes to clients willing to pay for them; they definitely do that for some clients (some still get security updates for XP!).
But what really drove me nuts was when that hysteria extended to things that were clearly tabular. I remember trying to copy paste a list of transactions from the Morgan Stanley site and it just didn't work. Confused why I looked at the source and the "table" was in fact just a series of divs with a lot of CSS to make it look like a table. A table could be copied and pasted into a Google spreadsheet trivially. Instead I had to manually reenter the data.
I feel like a lot of this could have been prevent d had we simply created HTML elements called <grid> years ago.
<dl>
<dt>Term1</dt>
<dd>Term1 defintion</dd>
<dt>Term2</dt>
<dd>Term2 defintion</dd>
</dl>
and the task of organizing it into two columns table: dt's in first column and dd's in second. Impossible either with display:table & co. or with display flex.At the same time in Sciter[1] I can define that layout as
dl {
flow: row(dt,dd);
}
- replace dt/dd pairs in table rows. The table will have two columns. Pure styling without changes of markup semantic and structure.[1] CSS: Flow property and Flex units in Sciter: https://sciter.com/docs/flex-flow/flex-layout.htm
But even you can add some non-semantic DOM elements...
What if you have
<ol>
<li>first</li>
<li>second</li>
<li>third</li>
</ol>
And you want to replace them in two,three,etc. aligned columns (depending on view size), like these: @media handheld {
ul { flow:vertical; }
}
@media ... {
ul { flow:row(li,li); } // two columns
}
@media ... {
ul { flow:row(li,li,li); } // three columns
}Not necessarily.
I can define
form { flow:row(label, input select textarea); }
to have typical form's two columns layout with all <label>s go to first column and input, select and textarea go to second. All non-matching elements are replaced as if they span full rows (like <caption> in tables).People at trying to simulate these things by using float and clear. Ugly, non-reliable, etc.
[1] https://html.spec.whatwg.org/multipage/semantics.html#the-dl...
Yet this is not "resolution friendly".
dl { flow: row(dt,dd,dt,dd); }
Changing markup structure is not a good idea if to consider that the same markup shall be used on different medias.The other value the property can take, fixed, makes table layout way more predictable: with no width properties defined, an n column table will result in each column having an equal width. If you define a width on some columns, it will split the remaining space between the remaining columns. This is far more often what you actually want when laying out non-tabular data using display: table as a make-shift grid layout system.
I have decided for me at least that a fixed footer and header is what I consider my "holy grail layout" with just a center with no columns. Lately I've been trying to play with css grid to port over my previous layouts, but without much luck so far.
This
div { display:block }
div > * { display:block; }
is closer but still far from ideal: e.g. it will force all tables to lose their display:table; or lists to lose display:list-item;As far as I understand author is looking for
div { flow:vertical; }
But that's available only in Sciter. <div>
some text
<foo>first</foo><bar>second</bar>
</div>
There is no way in CSS at the moment to define content flow of the div above. The only possible way is to define `display` on its children.Say, you want that div to replace content vertically as if all children are blocks and text runs are wrapped into anonymous paragraphs:
<div>
<p.anonymous>some text</p>
<block.foo>first</block>
<block.bar>second</block>
</div>
That's impossible in modern CSS without redefining `display` in children. But usually you cannot blindly say div > * { display:block;}
What if some child uses `display:flex` ?Problem is that `display` defines how element is replaced among its siblings. But not how its children are laid out.
At some point it was a proposal to add `display-model` css property. So you can have
div { display: block; display-model:flex | table | etc }
Without it we have ugly semi-solution of combinatorial explosion: div { display: flex; }
div { display: inline-flex; }
div { display: table }
div { display: inline-table; }
div { display: grid; }
div { display: inline-grid; }
...This is of 2002: http://www.w3.org/TR/2002/WD-css3-box-20021024/#L706
15 years ago, Carl!