Would you use an HTML table, a data table, or something else?
Thanks
(The history lesson is free!)
Difficult. I think I might use a definition list.
Oops, yes thatâs what I meant by data table! Thanks TB.
I would use a table because I think formatting would be easier.
How is the source data formatted?
Yes I would.
Date in the first cell and Data in the second.
coothead
To match the formatting in the image I think a table would be harder to do.
Though ease of formatting should not take precedence over semantics.
It is debatable whether semantically this should be a table or dl, I think either could work.
This example shows the default styling of a dl
and how css can change it to be more like the format in the image.
Thanks guys!
Ah. It started out as a Word doc which I saved as HTML and spent many
happy hours tidying up! I reduced 117KB to 36KBâŠ
Maybe the formatting of your document is a bit different, but I find the amount of mark-up clutter in a Word to HTML export too much to bother with.
I do write articles in MS Word (or have them sent to me as). But when I transfer to HTML I do it manually, copying a paragraph at a time and pasting between <p>
tags in my HTML document (or other elements as appropriate, but an article is mostly made of paragraphs). It can be laborious on longer articles, but Iâm sure itâs better than removing all that clutter from a straight HTML export.
I donât know if there are any tools that will do an HTML export with clean mark-up, it would be nice.
Yes, thatâs what I usually do. In this case, I decided on a different route. I think itâs a case of swings and roundabouts, but yes the code was 'orrible.
Iâm sure I saw something a few weeks back. Iâm not so sure I didnât paste something in Slack. Let me see if I can find it.
Edit: This was the one - https://twitter.com/captainsafia/status/881551373212450818 - looks like it might be OSX only though.
I can use the details tag:
<details>
<summary>You can avoid summary if you want</summary>
<p>Content here</p>
</details>
PS-1: You can put whatever you like inside the details (even a second details tag) so why tables or definitions lists? Details are better for the/this job
PS-2 If you use the details tag after all, you must use a normal markup, e.g paragraphs, tables etc. Donât put just casual content.
Lack of support for <details>
in IE and Edge might make it less than an ideal choice.
Html5 indicates that Definitions lists (DL) are now data lists and can take any name/value content which means that the use you have shown is perfect for them.
There is a good discussion here (although a few years out of date) but the comments by Thierry and LEE are the most compelling arguments I think.
If you use a table then the first cell must be the th and the next cell the td (not just 2 tds in a row) because the semantics are then lost. A table would be overkill for this simple list but I have often used both depending on âuse-caseâ so its not a big issue either way.
An interesting article (and discussion).
Yes, I was thinking along similar lines before reaching those comments.
It is not the fault of the <dl>
that the SR doesnât interpret it well, but a fault with the SR. To be fair to the SRs, them pandering to unsemantic use of tables, lists and other elements is possibly born out on necessity due the the number of developers producing unsemantic code, possibly ignorant of lesser used elements like dl, while there are still old-school, legacy sites out there and Neanderthals still using tables for layout.
So the result is people avoiding proper semantics, instead choosing the elements the SR deals with best, and having to jump through hoops just to make SRs recognise table elements for what they actually are.
Should it really be necessary to give a <tr>
role of row
?
<tr role="row">
This is an absolute nonsense IMO. [rhetorical]
What on earth else could it possibly be?`[/rhetorical]
I think itâs backwards for devs (who know good semantics) to pander to the SRs which are pandering to the Neanderthals, as this means they are holding us all back to the stone(table) age of web design rather than progressing to a more semantic and readable web.
Iâm hoping, as was hinted at, that the SRs have improved since then.
I wanted to give another option except tables and definition lists. OK, itâs true that ie has a bug with the specific tag, but according to my opinion itâs better for someone to know that he has an extra choice than not to be aware of it.
You are absolutely right when you said about the bug. But generally itâs not an important bug really. To be more accurate, the only buggy thing, is that ie (donât know about Edge, sorry) doesnât understand that since someone did an action (i.e clicked over the details or summary elements), a result is required [open/close]. But that doesnât change the fact that you can use the rest of the code. If for example you only want a normal question/answer sheet:
Question: ???
Answer: âŠ
then you donât care if the «answer» must close after clicking over the «question». The whole thing that counts -well, according to my opinion at least- is to have a proper structure, even if a fancy effect cannot be applied and especially when it works in 99% of the browsers
Here is what I use (and itâs a common thing really⊠itâs not nothing special):
HTML CODE:
<a href="#open-me">Click to open the div</a>
<div id="open-me">
<ul>
<li>Li content here</li>
<li>Li content here</li>
<li>Li content here</li>
</ul><a href="#">close me</a>
</div>
CSS CODE:
#open-me:target {display:block;}
#open-me:not(:target) {display:none;}
Using the above trick you have the same effect as when you click the details/summary tags. And the cool thing is that you can use it simultaneously with these tags instead of a div. Of course most of the browsers will recognize two clicks (one of the original details/summary tags and one of the âopen-meâ clicked event) and explorer only one, (the clicked event) but I donât believe anyone would care about it, if the user prefers to have the choice to hide/close the «answer» in explorer, instead of not being able to close it at all. And from the other hand if the user doesnât care for one more click⊠well, he doesnât care so everything is fine.
PS: I must admit that youâre right though. Since I didnât explain all these my last post was incomplete. Sorry about that.
Iâm struggling to see how the use of <summary>
or <detail>
applies to the scenario give in the original post. Their use seems more related to behaviour than semantic markup; at least from the example quoted.
I think of <details><summary>
as kind of an accordion for a tl;dr in terms of itâs semantic use.
For date and historical event, it could be made to âworkâ. And if other means failed I might be tempted to use it. But I think for this example the choices should be between using a table or a list.
For only two fields I would lean towards a list. But if I thought other fields might be added later, eg. âhistorical importance levelâ etc. then Iâd go straight to a table.
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.