44

In What HTML tags are allowed on Stack Exchange sites?, Jeff explains which basic HTML elements are allowed. Near the end he states

We do not and will not allow table tags -- sorry. This is intentional and by design.

I am wondering what the rationale behind the decision is. I could see the difficulty in getting the tr and td elements to properly close for users not familiar with HTML, and perhaps how tables lend themselves to wasting too much horizontal real estate.

I'm not suggesting that tables be allowed in the SO engine, but I would like to know what pitfalls I can expect if I allow my users to enter them in my (soon-to-be-written) application that allows markup.

2
  • Voting to close as a dupe because the other question has an answer from a developer as to why Stack Exchange hasn't done it (including the pitfalls being asked about here), and this question has no authoritative answer. Jun 2, 2014 at 1:48
  • I believe the answer @doppelgreener is referring to that explains why SE hasn't implemented tables is this one from Shog9. It's a bit buried at the "dupe" question (0 net votes as of now, so it's low).
    – ruffin
    Jun 17, 2015 at 18:15

4 Answers 4

13

I imagine the reason is because Jeff & Co. don't want to have to worry about people using undesired markup elements which could potentially blow apart the site's layout.

It is probably easier just to say "no tables" then to have to make sure that tables don't screw things up.

3
  • 8
    Sloths!
    – Welbog
    Aug 21, 2009 at 19:30
  • 31
    You can't create a broken table with Markup. If the correct patterns aren't found, it doesn't create a table.
    – Sampson
    Aug 21, 2009 at 19:33
  • 1
    put the table inside some block element like IFRAME with strictly set bounds - and it would not blow nothing but itself Jan 16, 2013 at 11:46
11

Markdown doesn't actually have a markup syntax for tables. There are some add-ons that do, such as PHP Markdown Extra, but neither WMD nor whatever SO uses server-side supports them.

Jeff seems to be of the opinion that tabular data can be represented well enough using code sections so as to accomplish most tasks. I would imagine the extra expense of supporting and validating tables does not seem particularly worthwhile to the team.

4
  • 3
    Well, Markdown also doesn't actively disable the html table tags. Tables in markdown are just tables in HTML.
    – badp
    Jun 23, 2011 at 14:35
  • 1
    @badp: In the Stack Exchange network, the HTML <table> (and related) elements are actively stripped.
    – MrWhite
    Aug 4, 2012 at 12:24
  • 2
    @w3d Yes, but that is part of the html sanitization by Stack Exchange, not the markdown specification itself.
    – badp
    Aug 6, 2012 at 14:44
  • 1
    @badp: Sorry, in my haste, I thought you were implying that you could fall back to using HTML table tags on SO.
    – MrWhite
    Aug 6, 2012 at 16:37
6
I'm not suggesting that tables be allowed in the SO engine, but I would like to know what pitfalls I can expect if I allow my users to enter them in my (soon-to-be-written) application that allows markup.

If you allow users to enter html markup and you whitelist table elements without providing a proper pattern requirement, it's possible to affect any page's rendering which uses tables as a major layout component in most browsers, sometimes in some very interesting (and/or destructive) ways. Allowing users to generate tables through alternate means is often safer (non html markup run through an engine to create the actual table), if the associated logic pattern for the actual table generation is tight and can't break.

The gist of it is that you can break out of either cells or entire tables within a post (by using unbalanced closing tags), making the content you follow your break out with appear in odd places. This can happen even unintentionally with a malformed table. (unbalanced opening tags can have consequences involving table elements following the content)

I've actually seen this happen before on a major forum (arstechnica.com, back when html was more widely permissible). Unfortunately that was over ten years ago, so I can't link the thread (it involved someone trying to make a table for decibel levels leading up to eardrum rupture, which was fairly amusing when it ruptured the page).

If you're using divs for all of your layout you're probably fine. If you had strong whitelist pattern requirements for using table elements you would hopefully also be fine.

4

My guess is because Jeff & Co don't want to deal with the hassles that user-generated tables bring.

However, you can pseudocode tables by using the <pre> or code markup, since spaces are respected:

like   this   table
right  here   .

Malformed table HTML can screw up the site layout pretty royally. And that makes nobody happy.

4
  • 9
    I'm pretty sure you cannot create a malformed table with Markup :)
    – Sampson
    Aug 21, 2009 at 19:30
  • 14
    I'll create a malformed you with markup.
    – Eric
    Aug 21, 2009 at 19:37
  • 2
    @Eric - funniest thing I've ever read on MSO.
    – user208778
    Jan 21, 2013 at 10:19
  • 1
    @Eric - I can't stop smiling reading this comment... Apr 5, 2013 at 6:25

Not the answer you're looking for? Browse other questions tagged .