Live data from Hacker News

Ask HN: Is it just me, or is CSS too damn hard?

news.ycombinator.com

331–340 of 358 posts

Re: Ask HN: Is it just me, or is CSS too damn hard?

#331
post #302

> Is it common for other developers to have issues with it, or is it just me? Is there any material out there that made CSS "click" for you? If you're coming from an application development background, you will hate CSS layouting. It's the most ass-backwards way of structuring a UI that you will ever encounter. A lot of web people who never used stuff like Qt, Swing, Winforms (etc) just don't realize this. They think…

The thing is, Winforms et al. solves a much simpler problem. It only runs on one platform, it does not handle scaling gracefully, it does not even attempt the solve the complex problems of text re-flow to accommodate different size viewports etc. Swing is fine for cross-platform GUIs but can it render books in high-quality typography on various devices? (Or would it use a HTML rendering control with CSS support for t…

The complex problem of text re-flow is probably not that complex. It has been solved rather satisfactory in all word processors and desktop publishing systems.

Re: Ask HN: Is it just me, or is CSS too damn hard?

#332

Earlier quoted context omitted.

>Give me springs and struts, Autolayout, or PowerApp's style declarative positioning any day. Positioning is one thing, but CSS really shines in it's graphical abilities. Autolayout is fantastic, but have you tried writing the custom CoreGraphics code that is required to do anything outside of standard UIKit visuals? Not fun [0]. Being able to just type `background: linear-gradient(orange, green)` is a godsend compar…

Then I guess my dream system marries the two concepts, somehow. I don't think we should accept CSS just because it's what we have; far too many people find it confusing and dislikable. At this point, I'm starting to look into things that "transpile" to CSS.

IMHO I think that one of the main problems with CSS is that it doesn't have an explicit model of text. If you have that, then a constraint-based designer can take you through wizards to ask to to consider eg. When there's more text than space. Springs, struts etc. Can take care of layout. Controversially I think we should replace/remove div tags as they don't make all their behavior explicit vs flexbox/ cssgrid etc. Every object should have explicit layout behaviors defined. Then you can compose them or create new objects for undefined cases.

Re: Ask HN: Is it just me, or is CSS too damn hard?

#333
post #57

CSS is almost a failure as technology. None of it's promises has been realized. The idea with CSS was that we would be able to separate content from presentation. Remember CSS Zen garden? Yet that has never been the case and div tags were always needed to be able to display something simple. Another promise was that content would be displayed easily on different mediums, desktop, mobile even print.. yet it's impossib…

It's only a failure when viewed through the lens of application development. The web platform wasn't initially designed for applications, it was designed for documents. If you're crafting a document, you can separate style from content pretty neatly with CSS.

What if my style requires a triple outline around a header?

Re: Ask HN: Is it just me, or is CSS too damn hard?

#334
post #57

CSS is almost a failure as technology. None of it's promises has been realized. The idea with CSS was that we would be able to separate content from presentation. Remember CSS Zen garden? Yet that has never been the case and div tags were always needed to be able to display something simple. Another promise was that content would be displayed easily on different mediums, desktop, mobile even print.. yet it's impossib…

The straightforward way to separate content from presentation is to have a step that transforms that content into a specific form: 2D screen based, 2D page-based, aural, etc., including different purpose like a small read-only mobile gadget vs a full-screen desktop app. Web technologies actually have a beginning of this: XML source + XSLT processor, which is a general-purpose declarative tree transducer. But web community took a wrong turn here.

Re: Ask HN: Is it just me, or is CSS too damn hard?

#335
post #302

Earlier quoted context omitted.

The thing is, Winforms et al. solves a much simpler problem. It only runs on one platform, it does not handle scaling gracefully, it does not even attempt the solve the complex problems of text re-flow to accommodate different size viewports etc. Swing is fine for cross-platform GUIs but can it render books in high-quality typography on various devices? (Or would it use a HTML rendering control with CSS support for t…

The complex problem of text re-flow is probably not that complex. It has been solved rather satisfactory in all word processors and desktop publishing systems.

Sure, but it is not solved by GUI toolkits like winforms, which is why they are not directly comparable. And A DTP system will not gracefully adapt the layout if you change the page dimensions or scale up the font.

My point is just that CSS is designed like it is because it tries to solve some particular problems. If you expect it to work like a GUI toolkit (or DTP program) you will be confused because they do not try to solve the same problem.

Re: Ask HN: Is it just me, or is CSS too damn hard?

#336
When I was struggling with CSS at my first job (2011), the thing that made it click for me was learning the significance of the `display` property and its possible values. After I learned that each `display` value causes the element to be rendered in a certain way, and that some CSS properties were only useful for certain `display` values, it became much easier to predict how the layout would look and to organize the CSS properties in my head.

For example, it cleared up a lot of questions when I learned that `display: block` elements naturally expand to the greatest width they can while matching the height of their contents.

Also, the Mac app CSSEdit (now folded into Espresso; https://espressoapp.com/) helped me learn the various CSS properties thanks to its GUI interface that listed properties by category, such as Text, Decoration, and Layout. It had icons for each possible value of each property that made it easy to remember what values each property supported. A useful feature of the app was letting me load an arbitrary web page and edit its styles with its GUI editor – I could see which properties were more often useful and how switching the between the possible values would change the look.

Re: Ask HN: Is it just me, or is CSS too damn hard?

#337
post #142

Earlier quoted context omitted.

CSS is not a real constraint language. If it really were a constraint language, it would be better. There's no constraint solver. Just a bunch of rules applied sequentially. I'd like to have a real constraint system, like the one in Autodesk Inventor sketch mode. You select two things and apply a constraint - parallel, tangent, horizontal, collinear, etc - and the constraint system enforces those constraints. The lay…

> Amusingly, tables came back. But they're called "layout tables" now, to avoid embarrassment. I'm not really sure what you're talking about. Tables were bad because they were too rigid and weren't designed for layout purposes; they do still get used when you want to display an actual table. Maybe you meant CSS Grid? > Trying to do 2D layout with 1D constructs (the "float" and "clear" era) was just silly. The float e…

The DOM is actually a tree. I'm not sure if it's correct to call that 1D. Similarly, the web is a graph, definitely not 1D.

I'd even go as far to say the text on most webpages isn't even linear. It's either a tree (like this comment page) or a fragmented collection of text chunks.

The webpage that strictly consists of one linear stream of text is very much the exception. And it also happens to be the exception that CSS never had problems with.

What you seem to be saying is that paragraphs are 1D (which get wrapped and flowed in layout), therefore entire webpages are 1D (no) and therefore the web is 1D (definitely not).

Or maybe you could say that most viewport representations, scrolling vertically, are 1D. In which case CSS should be the tool that converts the tree or graph of content into this semi-1D viewing representation.

I agree that this mismatch is where CSS finds a lot of problems.

Re: Ask HN: Is it just me, or is CSS too damn hard?

#338
post #274

Earlier quoted context omitted.

Here’s the [parent project][1] and the old [research page][2] at University of Washington. The most recent implementation is Rust in 2018. The JavaScript repos are inactive. I’m not sure if that’s because the algorithms are considered complete or because the project is dormant. One of the researchers is no longer at UW and the other is an emeritus professor, so semi-retired. The claim is Apple uses these layout algor…

Too bad. That was the right idea. With that, we could have Dreamweaver type layout working again. That project seems to be more about the math than making layout easier. That's a problem with many academic projects. One thing I've liked about Autodesk products is that they often have complex math inside, completely hidden from the user. You see that in the CAD world, where the physical universe has to be modeled.

> Too bad. That [constraints] was the right idea.

In theory, yes.

And the theory certainly can work beautifully as intended in practice.

However, developers and designer tend to have huge problems with autolayout. Specifying what you want visually as a set of linear constraints is challenging. It is very easy to get very surprising outcomes, easy to overconstrain and underconstrain.

It's a very big sledgehammer aimed at some very delicate eggshells. Not just when it comes to understandability, but also when it comes to runtime performance.

Re: Ask HN: Is it just me, or is CSS too damn hard?

#339
post #330
post #307

Earlier quoted context omitted.

Who is "you" in your scenario? It would be similar to printer formatting languages. The printer driver translates a document into lines, vectors, and polygons, and sends those to the printer as page coordinates, except the page length is not limited to paper's limit. (We'd probably have to add event triggers on designated polygons to handle UI interaction.) The equivalent of the "printer driver" is the rendering engi…

My question was, how would Google index pages and make them searchable in this system?

My main focus is on "productivity" applications and CRUD, not so much documents. One doesn't typically index applications in a Google-esque way. I don't propose we throw out all the Web, but rather create (or extend?) standards for the things HTML/DOM/CSS do poorly. My apologies for not making the scope clearer. (Maybe that's why I got a "-1" score.)

And, there may still be a markup language with text as text and other semantic info. The new standard may be able to use existing HTML tags, but add supplement attributes to control precise placement, and other features HTML/CSS lacks.

By the way, Google can index PDF documents reasonably well, depending on how the PDF was created. This is evidence that precise control over layout doesn't necessarily prevent indexing and summarizing of text and content.

I will also point out that many graphic designers are frustrated with CSS also because they envision a concept, but have a hard time getting web pages to do what precisely what they envision. It's why Flash was popular with them: the proverbial paint strokes wind up exactly where you put the brush down on the canvas. The artists may still want their work to adjust to the end-user screen size, but they want to control precisely HOW it adjusts: they want to write the size adjustment formulas themselves (or select among multiple API's), not rely on browser programmers and their variation on the CSS engine, which often differ across browser brands and versions.

Re: Ask HN: Is it just me, or is CSS too damn hard?

#340
post #339
post #330

Earlier quoted context omitted.

My question was, how would Google index pages and make them searchable in this system?

My main focus is on "productivity" applications and CRUD, not so much documents. One doesn't typically index applications in a Google-esque way. I don't propose we throw out all the Web, but rather create (or extend?) standards for the things HTML/DOM/CSS do poorly. My apologies for not making the scope clearer. (Maybe that's why I got a "-1" score.) And, there may still be a markup language with text as text and oth…

Can't you already do everything you propose with the HTML canvas element then?

But I can't see why you would want to render something as mundane as a CRUD UI through such a complex and slow scheme. For perhaps a game or some truly unconventional UI, it makes sense to use SVG or canvas to render it. But then you also want the rendering logic on the client (in JavaScript) because it would be far too slow to round-trip to the server for each mouse movement.

Btw. Google can index PDF files only because the PDF format contain text in the form of character strings, not as drawings or bitmaps, as you suggest.

Post reply on HN