The Document Object Model (DOM) is a language-independent model made up of objects representing the structure of a document. HTML is one language for writing such documents.
Не проще ли тогда уж разобраться в html и css?
решение будет очень громоздким, негибким и трудноподдерживаемым. Оно вам нужно?