11

I recently saw in the W3Schools html tags reference two attributes I don't quite understand. The first is the <table sortable="sortable"> attribute, and the second is <th sorted="sorted"> attribute.

According to W3Schools, the sortable attribute description is:

Specifies that the table should be sortable

And the description for the sorted attribute is:

Defines the sort direction of a column

And the values the sorted attribute accept are:

reversed
number
reversed number
number reversed

I tried to follow the W3C documentation here about how to use those attributes but it doesn't works for me.

I would be very thankful for an answer. Thank you.

Michael Haddad
  • 4,085
  • 7
  • 42
  • 82

2 Answers2

31

In 2016, the table sorting model (including "sortable" and "sorted" attributes) was completely removed from HTML5.1 draft, due to lack of implementations.

Reference: https://github.com/w3c/html/issues/56

X. Liu
  • 1,070
  • 11
  • 30
  • This does not provide an answer to the question. Once you have sufficient [reputation](http://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](http://stackoverflow.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](http://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). - [From Review](/review/low-quality-posts/12986542) – Taylan Aydinli Jul 13 '16 at 07:30
  • 17
    @vape Sorry but I think that my post does answer the question. OP asks "I tried to follow the W3C documentation here about how to use those attributes but it doesn't works for me." My answer says 1) W3C already removed these attributes, and 2) no browsers have ever implemented these attributes, so it doesn't work. I know this question was asked years ago, but I had exactly the same question the OP had, and I searched and found the link I posted. I thought this info may be useful for others, so I post an answer here. Hopefully I didn't violate the rule of Stack Overflow. – X. Liu Jul 13 '16 at 08:20
  • 4
    it's 2017 and you've saved me some time researching.. the only reason your answer looks like a comment for some, is at the beginning of the sentence when you say "Note that.." Remove that and it's a completely valid answer.Anyways, silly they havent implemented a sorting method where clearly it's a very much needed feature. Back to JS I go... – Sergio Alen Oct 19 '17 at 02:44
  • 1
    [Sorting HTML table with JavaScript](https://stackoverflow.com/questions/14267781/sorting-html-table-with-javascript) – handle Dec 18 '19 at 11:14
  • Please use aria-sort instead! This is supported by assistive technology and is properly specifed and documented. For example at https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-sort – brennanyoung Feb 14 '23 at 09:55
18

The W3C document your are referring to is a draft for HTML 5.1, which is scheduled for publication in 2016 and not implemented in any browser today AFAIK (hey, HTML 5 is not yet fully implemented and targets feature freeze in june 2014).

Now, if you need sortable table, there are plenty javascript-based libraries out there that can do that.

Pierre Rust
  • 2,474
  • 18
  • 15