Take the 2-minute tour ×

As I said in the title, isn't TeX "similar" to static web pages? Can you accomplish the same things with both, or is TeX limited to words?

Why would one prefer HTML and CSS over TeX, or vice versa?

share|improve this question
They are used for quite different media (though granted, these media are to some part slowly converging). –  Caramdir Mar 30 '11 at 3:40
The answers to Why couldn't (La)TeX's layout model be as simple as CSS's layout model? are relevant to your question. –  Charles Stewart Apr 20 '11 at 7:45
But, how identify precisely what is the current gap between LaTeX and the trio CSS3+html+Javascript typesetting? We should not consider the problem of the readability of the trio, once an IDE could solve this. –  Lauro César Feb 17 '13 at 11:51

3 Answers 3

up vote 7 down vote accepted

Without considering JavaScript, it is a bit different to compare, because one is then restricted to the features which CSS and the HTML box model provide. Layout-wise, this means that you cannot do automated positioning of characters, which depend on the position of other things of your layout. You cannot, e.g. use proper margin notes or automated footnotes.

However, in principle these things could be arranged by the author, if – and that is a strong ‘if’ – one were writing for only one interpretation of one browser with a certain font.

HTML alone is (theoretically) much stronger in the semantic interpretation of data than is tex, but this is not relevant for the typographic representation. (It is of course indirectly connected to the representation by typographic conventions.)

When adding JavaScript, however, one can in principle add all* of the features which tex offers, though it may look a bit nasty and involves a lot of DOM hacking. Note that JavaScript may especially also be used to create embedded graphics or help with automatic hyphenation and mathematical formulae. It may involve more files to be loaded but that’s true for tex as well. And also, it will take a longer time to render just as tex takes its time to create a complicated page.

Still, it is really complicated to produce cross-browser and cross-system compliant documents this way, which is one reason that no such complicated framework has evolved yet. (Another reason is that it is not needed that badly.)

*: One feature which is hard to add, is proper font support on the scripting level. With current techniques, it is especially hard to get e.g. kerning information or OTF glyphs out of the font files – all of that is being handled by the browser and even the most advanced and specialised web design will need to rely on the browser’s mapping between unicode character and OTF glyph. This will most probably change at some point in the future as the typographic techniques converge. (See: http://hacks.mozilla.org/2010/11/firefox-4-font-feature-support/ )

share|improve this answer

No. You have pretty much no control over how pages break with HTML+CSS (or if you have, please share how). Besides, you are comparing apples to oranges: TeX is a typesetting system, HTML+CSS isn't.

That said, you can make, with some effort, typographically appealing documents in HTML+CSS with the help of, for example, a Hyphenator and some info on the basics.

share|improve this answer
You have: w3.org/TR/CSS2/page.html –  Debilski Mar 30 '11 at 8:29
@Debilski: I was aware of the specification, but I'm not aware of any actual working implementation (Although, I only remember for certain trying it out with Webkit/OSX). –  morbusg Mar 30 '11 at 14:07
@morbusg: I'm a bit confused: why would you want to have page breaks in a web page? –  Bruno Le Floch Mar 30 '11 at 21:57
@Bruno: CSS lets you specify rules that only apply when the page is printed. –  Caramdir Mar 31 '11 at 3:16
@Bruno: if one is going to compare TeX and HTML+CSS, I felt it only makes sense when printing HTML+CSS (ie. @media print). –  morbusg Mar 31 '11 at 3:24

TeX is a Turing complete programming language. I haven't seen any browser plugins yet written only using HTML and CSS. There are hundreds of from small till giant packages for (La)TeX, like PSTricks and TikZ. Ok, you could draw your vector graphics with SGML, but please compare the code required for that and e.g. tikz.

TeX includes algorithm for line and page breaking and HTML+CSS does not. Compare a PDF produced with DocBookXML compiled with Apache FOP to PDF, or simply a website printed to PDF and one made using LaTeX, then you can see the difference in typesetting quality.

TeX allows for automatically generation of e.g. table of contents and other lists. This doesn't work with HTML+CSS out-of-the-box. Same counts for references and citations.


share|improve this answer
I think mentioning the line-breaking and page-breaking algorithms is a bit unfair. You don't need on-the-fly text reflow in a PDF, as you do on a webpage. –  Jubobs Sep 23 '14 at 19:13

Your Answer


