Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Every now and then I need to compare LaTeX to HTML to someone, and it can be hard to give a succinct answer that demonstrates the purpose of both, and why one wouldn't want to abuse one for the purpose of the other.

Also, the differences cover several areas, such as target medium, layout vs markup, and so on.

Perhaps this would be a good place to collect a few answers for later reference.

share|improve this question
Hi Nyiti! Although your question seems interesting, I think that it will be closed as being "not constructive". We are quite sensitive on such questions, because we really want to avoid discussion and posting "opinions", and this question basically asks for opinions. The fact that all the questions are kept to be very specific and non-vague makes this site so valuable. I hope you understand this, and if you had any questions, feel free to ask (for instance in the site chat). –  tohecz Oct 18 '12 at 17:32
add comment

closed as not constructive by tohecz, Kurt, Mico, cgnieder, I am who I say I am Oct 18 '12 at 17:53

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.If this question can be reworded to fit the rules in the help center, please edit the question.

1 Answer

up vote 5 down vote accepted

I'm assuming you're asking about CSS in combination with HTML, since otherwise you can't really get any styling into an HTML document. There are plenty of differences — though don't forget about the many similarities as well.

(La)TeX has a very good knowledge of typesetting requirements and media.

  • (La)TeX will justify text, automatically hyphenate, provide proper spacing, and other typesetting features. (You can use XeTeX for even more typographical features.) The default article class has the text width optimized for readability. Most browsers don't have this type of functionality, and with HTML/CSS you have to manually specify sizes.
  • (La)TeX will paginate content and you can set up different page styles based on left/right pages for physical publishing purposes. HTML has no intrinsic knowledge of "page layout" in terms of a single physical page of paper. You can specify print-specific layouts with CSS, but pagination is not trivial.

(La)TeX and HTML have different positioning systems.

  • Some things are similar, like the layout of text in regions, and fine-grained position adjustment, but one primary way of positioning stuff with CSS is "floats" which allow much more control over positioning than LaTeX floats. At the same time, \hfill doesn't really have a CSS equivalent unless you use tables.

Cascading Style Sheets are cascading.

  • With CSS you can specify styles that are based on a hierarchy of elements on the page, rather than LaTeX's scoped inline style commands. Elements automatically inherit most of the styles from their parent but can be overridden based on any number of factors.

HTML documents are live and responsive.

  • You can't scroll sections of a typeset LaTeX, nor can you make extensive use of JavaScript to manipulate and live-update elements on the page.

  • CSS has @media queries that let you provide different layouts for different target media (everything from screens and printers to screen readers and 3D glasses — anything that any client uses), as well as different viewport sizes.

  • HTML is most often written with the expectation that it will be used in a browser, so it is very common to take advantages of features like the navigator object in JavaScript, "visited" link styling, etc. Nowadays, on mobile devices, you can even get access to hardware sensors such as an accelerometer or GPS.

Browsers get to make up their own features!

  • The only real authorities on what you can do with HTML and CSS (and JavaScript) are the browsers themselves. Many browsers have implemented exclusive new features, and these often lead to spec updates and eventually more widespread adoption. With LaTeX, the available features are dictated by what version of LaTeX you're using, and what packages are available.
share|improve this answer
add comment

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