htmlobsolete

How do I replace axis attribute in HTML5?


I'm trying to have a script that will convert obsolete HTML in an old website to valid HTML5, but I'm struggling to find the replacement for the axis attribute.

The axis attribute on td and th elements was apparently meant to set a category on table's (header) cells.
According to https://dev.w3.org/html5/pf-summary/obsolete.html, it should be replaced by the scope attribute.

However, the scope attribute tells wether that the th element is a header for a cell or a column, but it does not put categories on table elements. Moreover, using the scope attribute on a td element is obsolete and it can only be used on a th.

So how to replace the axis attribute ?


Solution

  • There's no direct replacement for axis in HTML 5, largely because browsers never did anything with it beyond exposing it on the DOM.

    If there was a page which made practical use of it, then it would depend on JS in the page. The modern equivalent would be a data-* attribute but that would require that the JS be updated as well as the HTML.