There is no simple way, for several reasons. The align
attribute has different meanings in different tags, and different CSS codes would be needed. For td
alone, it would be simple, but then you would need to combine text-align: ...
with existing content in style
attribute if present. In effect, you would need an HTML parser and a CSS parser.
The cellpadding
attribute has never been valid and does not work in td
, only in table
. Replacing it with style
attributes would mean that you need to put such an attribute in each and every th
and td
in the table.
Other presentational attributes can be more tricky. HTML5 has a complicated section on Rendering, describing (among other things) the “expected” effects of presentational markup in CSS terms (these descriptions does not quite match reality, but mostly they do).
And the result would still not be the same in all cases. Presentational attributes in HTML have a special role in formatting, and it cannot be described in CSS (it is described in CSS specifications, but you cannot express it in CSS code).
(The features are not “depreciated” in HTML5, but “obsolete”. This means that browsers are expected to keep supporting them. There is no good reason to “clean up” them on old pages—there is no possible gain, and there are loads of problems that the “clean up” causes, especially if mistakes are made in it, and human beings make mistakes.)