Hacker News new | ask | show | jobs
by datavirtue 1550 days ago
Exactly. CSS is doing too much. All the decisions seemed to make sense at the time but it all ends up being a clusterfuck. Part of it has to do with everyone having to rebuild HTML/CSS parsers from scratch and the ever changing and evolving nature of the markup.

Just when you think everything is going to be OK you are faced with feeding your document into another parser that isn't at parity with the browsers. A lot of people struggle to build PDFs from HTML where the parser (itext) only understands a certain subset. That nice grid layout you designed? ...throw that out. You need page breaks with common headers and footers? Get ready to commit some really dirty hacks. Should this data be in a div table or a semantic table? Better predict the future.

1 comments

Why do you need to rebuild parsers from scratch? You can just use Chromium. Want to build a PDF form an HTML page? You can launch chromium in headless mode and tell it to print your HTML. Guaranteed that you will have a good result. I don't understand where you have this problem these days.

Also, nobody really asks you to do complex things with CSS. Unless you use a huge framework (that I tend to avoid, I prefer writing everything from scratch) you don't need too much rules to make a page look good. In 200 lines of CSS you can get a good style for your site.

The problem is that people:

- think that frontend development is easy and have less dignity than other kind of software development - don't want to spend time learning CSS since it should be simple - don't know CSS and don't understand it - use a framework like Bootstrap because they don't want to learn CSS - complain that CSS is shit because they have to use a ton of !important to make things work

CSS is easy if you dedicate enough time to learn the basics of it, and start to make some stylesheets from scratch without Bootstrap or other shit.

Nobody wants to ship Chromium with their pdf library or application. How do I get a print preview? If I do convince myself to lug around chromium, do I invoke Chromium each time for 1000 PDFs in a batch? Do I want to pay to invoke chromium on a EC2 instance or lambda?

Every document production library that handles HTML (a very popular feature) has had to implement HTML/CSS parsing.

I and many others are using HTML and CSS to declaratively lay out complex , dynamic documents (or trying to at least). Seems to make sense but we have ten more years to go before it's fully solved. Right now it costs serious coin to do it (unless you are releasing FOSS) and it ain't fun.