I feel CSS's layout model is simpler than (La)TeX's layout model. At the time Knuth developed TeX, the idea leading to CSS model is a "difficult" things? Or the CSS layout model is not appropriate to be applied to (La)TeX.

  • 2
  • 11
    You seem to be (a) presuming that CSS is superior to LaTeX for laying out boxes and (b) asking why Knuth didn't invent CSS. This doesn't seem like an answerable question. – Matthew Leingang Dec 3 '10 at 12:21
  • 2
    You might be interested in the relatively new packages mdframed and adjustbox that have some very CSS-like features. – JohnJamesSmith Nov 27 '11 at 3:27
  • TeX's goal is to match the finest-quality books: Knuth was working backwards from the problem of reproducing the first edition of Volume 2 that had been typeset with the best of 500+ years of typographic tradition. As the first page of The TeXbook says, "If you merely want to produce a passably good document—something acceptable and basically readable but not really beautiful—a simpler system will usually suffice." And some of the difficulty here comes from using not plain TeX but LaTeX, which is a profound idea (logical structure) but implemented as a giant hack (because written in TeX). – ShreevatsaR Jan 2 '17 at 2:14
  • But see tex.stackexchange.com/questions/146440/… (which leads to wiki.contextgarden.net/Command/definehighlight) for something vaguely similar in ConTeXt (which in some ways is closer to plain TeX in spirit). – ShreevatsaR Jan 2 '17 at 2:26

If you read the Ph.D. thesis of Håkon Wium Lie's you will see that a lot of the concepts of CSS were based on TeX and LateX. Wium Lie and all the other contributor's to CSS came up with a system of separating content from presentation for HTML. The numerous forums and tutorials on the web is an indirect proof that the CSS model is not the best either. You probably find it easier as you are used to it. In addition CSS does not provide any means of programming. This has to be done via JavaScript. It also cannot help with mathematics etc.

When Knuth invented TeX, there was no Computer Science, no web, no html and no CSS. My personal opinion is exactly the opposite. If html was marked as LaTeX life would have been easier, the web would have looked better etc. If there is one aspect that I agree with you is the lack of a <div></div> concept and the ability to float sections left or right. This can be done using TeX but not as easily. There is an XML version of LaTeX called tralics perhaps you can have a look as to how it could have looked!


The current shortcomings of CSS/html can easily be observed by the fact that there are over 500 billion pdf documents on the web and the best way to create a pdf currently is with one of the TeX->pdf engines.

  • 25
    huh? "there was no Computer Science"??? tex was invented to typeset the second edition of "The Art of Computer Programming"; the first was composed in hot metal by a skilled monotype operator, and knuth's goal was to emulate the look of the first edition with which he was very pleased. – barbara beeton Dec 3 '10 at 22:17
  • 8
    @barbara For completeness I should have said and Computer Science was at its baby steps. The Foundations were laid out by books like the Art of Computer Science' and by conferences such as http://ieeexplore.ieee.org/xpl/mostRecentIssue.jsp?punumber=4567951 and plenty of discussions and papers on the GOTO statement! We still have debates, if it is science, mathematics art or engineering, but granted CS can now be considered a teen'. Thanks for the comment and the sharp eye. – Yiannis Lazarides Dec 4 '10 at 12:51
  • 11
    The existence of billions of pdf documents does not imply that TeX is superior to HTML/CSS. That only shows that PDF is the holy grail when it comes to "portable" documents, that is, documents that will print the same everywhere. I also wonder how many of those billions of documents are produced by TeX (outside of math heavy disciplines, of course). Think brochures, magazines, and the like. – Aditya Apr 9 '12 at 3:44

Note that the CSS layout model is not simple, because it includes a concept of stitching together boxes both horizontally and vertically, which is tricky (1) . The apparent simplicity of CSS lies in how parameters are passed to the layout engine, through stylesheets; by contrast, Tex uses a famously hard-to-master programming language to associate these parameters with the objects in the layout's domain model.

Also, there is one universally recognised reference implementation for Tex; CSS versions one and two were introduced during periods of intense fighting in the browser wars (2), which made it easy to produce some sort of document with the CSS2 box model, but far harder to ensure a good reader experience that with Tex.

The other important, growing Tex-based typesetting platform, Context NG, actually does permit specification along the lines of style sheets, using its \...setup commands and its supported for named setups: to the extent that this is more complex, it is in small part due to the historical tie to Knuth's macro language and the larger part due to supporting far more sophisticated layout needs. I seem to recall there was substantial work done in the Context world on laying out directly from simplified CSS stylesheets; links to the current state of this technology would be appreciated.

The why is about ideas: the ideas about programming languages, document presentation, and abstraction that guided the design of CSS came after Tex. Both Context and Latex have aimed to reduce the coupling of layout issues from content. It's an ongoing effort.

(1): I say a bit more about comparative complexity in my answer to What are the differences between the CSS and Latex box models? at Stack Overflow

(2): Read Nicole Henning's from-the-library-trenches account of the browser wars, from the perspective of MIT's efforts to promote internal usage of web standards. Now, with CSS version three, there is no dominant browser; instead, the HTML5 and CSS3 web standards represent a sort of peace treaty.


Even worse, unlike CSS, LaTeX is not intended for unattended typesetting.

For this reason, I now resort to automatic CSS typesetting with PrinceXML for any content that is longer than a letter and not commercial nor academic. The PDF printouts on my web site are generated this way without any user intervention.

If you think of it, HTML+CSS is exactly intended for that: unattended typesetting on screens of unpredictable dimensions. A printed page is merely another media viewport.

With Prince XML one is in good company as more and more professional DocBook users are trading in XSL-FO for automatic CSS typestting. Prince XML is a commercial product though. If it were to pursue a FLOSS business strategy, its adoption rate might well skyrocket.

On print-css.rocks, one can follow the latest developments in unattended CSS paged media typesetting.

Besides that, ConteXt comes much closer to the CSS mentality than LaTeX.

  • If you want a FOSS alternative to PrinceXML, there's WeasyPrint. Looking at the available tools on print-css.rocks you listed, it appears to be the only FOSS option, unless you want to use some workaround like printing from the browser. Although there are bugs with certain cases, it seems to work fairly well for me so far. – TUSF Jan 15 at 22:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.