I've been given some legacy, table based code that I'm supposed to make html4/strict.dtd complaint.

Is there any technique to removing inline styles and old html attributes that should be css and making them into css?

  • Well this isn't quite related but it's close...I wrote a blog post about removing unwanted attributes from particular tags using a regular expression and a regex-enabled text editor. It's still in draft so please tell me what you think: http://leeand00.tiddlyspot.com/#[[Removing%20Proprietary%20Attributes%20from%20html%20tags%20in%20Awful%203rd%20Old%20Third-Party%20HTML%20Code%20Using%20Regular%20Expressions]] Andrew J. Leer over 9 years ago
  • Here's an easier URL to follow: http://digs.by/vdX Please give me feedback on this. Andrew J. Leer over 9 years ago

2 answers


I would take a full assessment of how many repeat styles you have, those become your classes. The non-repeated styles that are for your main areas are your id's.

There's no fast way to do this. If you are looking to break out of the table and into a pure web standards design, then the best way is to wireframe your current site and replace your tables with divs/other semantically correct elements. Then look at the inline styles and apply your classes/id's for those sections.

A quick example:

Your table has 5 tds merged into one that represents a header. The inline style has an img tag and background-color and color tags, and some font tags for a menu, maybe,

Replace that with one div that has an id to represent that. Inside your id would be the image for the background, a background-color, a color for your fonts. Inside your div, you would have an inline ul to represent your menu. Your body tag would set up your general text for the whole site, and maybe some class(es) to alter the text just for the menu/text inside the header div.

And so on...

Converting isn't fast, but well worth it when your load times and search engine rank improve.

Answered over 9 years ago by tahdhaze09
ritch0s 46

Try running your code through: http://dirtymarkup.com/ it might help clear your dirty markup, however you might have to do the CSS styling yourself.

Answered over 9 years ago by ritch0s