To date, I have generated html files using htlatex rather than xhtml.

This has been for one simple reason. I can right click on the html file and open it in MS word to then save and distribute to my collaborators...

Because I have to save to a different format anyway, I could probably copy and paste the contents manually rather than a save conversion if there were xhtml specific features that I could benefit from making use of. I used to manually code html files way back in the day, before the internet got so helpful.

So, what are some of the pros or cons of using html vs html.

  • maybe mathml or mathjax
  • figure or equation inclusions?

I am kind of suspecting there are some good reasons for using xhtml because some of the top contributors here are using MWE with xhtml base config files.

I think a summary here could be a good reference point for beginners doing a review of possible tools before settling on their infrastructure.

  • with browsers as currently configured and html(5) as defined there are no advantages at all in serving xhtml files on the open web. Using the XML form has advantages in production if you are using an XML pipeline but there are no advantages to using XML in the final served form sadly. Commented Jul 15, 2015 at 20:30
  • @DavidCarlisle I see what your saying. I wasn't aware that tex4ht config files were html(5) compatible (I expected, obviously, certain amounts of backwards compatibility - but new libraries and coding to convert tex with said would be unavailable because of when tex4ht was written) but I guess this explains why I see no differences between formats.
    – EngBIRD
    Commented Jul 15, 2015 at 21:02

1 Answer 1


I personally prefer xhtml output from tex4ht because default option leaves <p> elemensts unclosed:

<!--l. 3--><p class="noindent" >Hello world


vs xhtml:

<!--l. 3
 class="noindent">Hello world


also if you use mathml, xhtml is preferred over html 4 AFAIK. But other than that, it probably doesn't matter in practice nowadays, as David says.

regarding html 5, it is not supported by default, but you can configure tex4ht to use it with simple config file:

\Configure{DOCTYPE}{\HCode{<!DOCTYPE html>\Hnewline}}
\Configure{@HEAD}{\HCode{<meta charset="UTF-8" />\Hnewline}}
\Configure{@HEAD}{\HCode{<meta name="generator" content="TeX4ht
(http://www.cse.ohio-state.edu/\string~gurari/TeX4ht/)" />\Hnewline}}
         rel="stylesheet" type="text/css"
         href="\expandafter\csname aa:CssFile\endcsname" />\Hnewline}}

and the resulting file:

<!DOCTYPE html> 
<head> <title></title> 
<meta charset="UTF-8" /> 
<meta name="generator" content="TeX4ht (http://www.cse.ohio-state.edu/~gurari/TeX4ht/)" /> 
<link rel="stylesheet" type="text/css" href="sample.css" /> 
<!--l. 3--><p class="noindent" >Hello world


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .