One can use \Configure after \begin{document}
These are from Michal Hoftich.
(untested, just an idea): \documentclass{article} \ifdefined\HCode \newcommand\html[1]{% \HCode{#1}% }% \else \newcommand\html[1]{}% \fi \begin{document} \html{<div class="hello>world</div>} \end{document}
And
You don't need \Preamble and \EndPreamble in your document, they are useful only in config file. You can use \Css, \Tg or \ConfigureEnv, but only after '\begin{document}'. Something like this should work: \documentclass{article} \usepackage{somepackage} \begin{document} \ifx\HCode\undefined \else \Css{body{background-color:green;}} \ConfigureEnv{quote}{\Tg<quote>}{\Tg</quote>}{}{} \fi \ifx\HCode will ensure that this code run only when tex4ht is loaded.