When running htlatex <filename> one can include CSS code via \CssFile and \EndCssFile. This works fine as long as the code is included directly in the main document body.
I suspect this is the usual problem of including verbatim content in a macro, but is there a way to include CSS code but not have to put it in the actual document body.
Notes:
pfdlatexruns fine on both of these, problem is only withhtlatexin the second MWE below.- The CSS included is not really used in the HTML to be generated from this MWE.
Code: Works, but document is cluttered
\documentclass{article}
\usepackage{ifpdf}
\begin{document}
%% This works, but would rather it not be here so that the document is not cluttered.
\ifpdf
\else
\CssFile
/* css.sty */
.imageWrapperHi { height:99%; width:100%; text-align:center; page-break-inside:avoid; }
.imageWrapperHi img { display:inline-block; height:100%; margin:0 auto; }
\EndCssFile
\fi
% -------
Some text.
\end{document}
Code: Desire a solution such as this
\documentclass{article}
\usepackage{ifpdf}
\usepackage{etoolbox}
\ifpdf
\else
\AfterEndPreamble{%
\CssFile
/* css.sty */
.imageWrapperHi { height:99%; width:100%; text-align:center; page-break-inside:avoid; }
.imageWrapperHi img { display:inline-block; height:100%; margin:0 auto; }
\EndCssFile
}%
\fi
% -------
\begin{document}
Some text.
\end{document}