Live data from Hacker News

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

news.ycombinator.com

221–230 of 358 posts

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

#221

Earlier quoted context omitted.

> and there's no choice And this is the thing that many web developers miss. As they've begun to creep into the mobile and desktop space, intent on replacing native experiences with a continual barrage of non-native, bespoke apps, each with their own design, they've mistaken widespread availability with quality and utility — that HTML/CSS UIs are widely available is all to do with ubiquity and lessening an otherwise…

>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.

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

#222

Earlier quoted context omitted.

> Your Autodesk comparison belies a fundamental misunderstanding about the nature of the DOM - it is, to its great advantage, a 1D space which flows into a 2D shape. What's the advantage? The screen is 2D space. Layouting is a 2D problem. Images are two-dimensional. It's simpler to start from 2D and make 1D content fit that space than the other way around. > The web is 1D because text is 1D. That made sense in the ve…

Humans can only focus on a single thing at a time. As your focus goes through any content, it necessarily follows a 1D path. HTML, eint Text, is also one-dimensional. CSS, as said before, transfers this 1D information into the 2D representation on a scree, or a printout. Or it leaves it allone, or rearranges the 1D stream, for a different 1D representation to a screen reader. This has nothing to do with being a “hist…

https://en.wikipedia.org/wiki/Apophenia

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

#223
Yes, CSS is a hot mess for a few reasons that all basically boil down to historical baggage.

CSS was designed for an era where the web was made of documents, probably closer to the environment of a modern ebook than a modern web app. In an ebook, you might want to set your fonts and spacings and so on, maybe even throw in a table or two, but the idea of "I want this box to appear exactly here"... well, you don't even know where here is! The paper size might be different, or the user might have custom fonts, or who knows what. The goal wasn't fine-grained control over visual design, but consistency across an organisation's published material.

Of course, "fine-grained control over visual design" is exactly what everyone wanted, even in the early days, so CSS grew in features and scope until today we have this decades-tall stratified monument to the art of pleasing everybody: a fully-featured typesetting, layout, visual design, animation and user interface language. But, however rich its top layers, the whole thing rests on a base of document publishing, and that can't be changed because You Can't Break The Web.

HTML has this problem also, which is why so many sites look like . In truth, the whole modern web is built on hacks that pretend apps are documents. A lot of that hackery (React, Vue, etc) is incredibly clever and sophisticated, but it's hacks all the same, and it only exists because the web is an app platform that wasn't built for apps. This hits CSS hardest because developers solve developer problems, and design isn't a developer problem. Unlike the DOM, the CSSOM isn't yet swaddled in enough layers of JS to fit in app world. That said, check out the various "CSS-in-JS" projects for some valiant attempts in progress.

I would say if you really want to really get CSS, you should start by using it as it was intended, typesetting simple documents with only CSS1 features (check it out, https://www.w3.org/TR/CSS1/ is so simple it makes your heart sing). Then work your way up through CSS2's additions, especially the positioning stuff (https://www.w3.org/TR/2008/REC-CSS2-20080411/changes.html#q1). Only once that feels coherent should you drink deep from the firehose: https://www.w3.org/TR/css-2018/#css

Or you could do what the rest of us do and pretend CSS makes sense while only using carefully-memorised avoid-the-dragons patterns, copy-pasting stuff from css-tricks, and fiddling with the result in the web inspector until it works. And, meanwhile, pray for Houdini: https://houdini.glitch.me/

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

#224
post #88

Earlier quoted context omitted.

The difference is that with JavaScript, you can install a linter and happily restrict yourself to the sane subset of the language. It's very realistic to never have to deal with any of the uglier parts of JS, even as a full-time front-end developer. With CSS, you can't avoid hacks. If you try to design anything non-trivial, you will have to employ tricky non-semantic tricks, run into edge cases, and have to settle on…

> 20+ years ago when a website page was thought as a 1 dimensional flow of text and pictures Here's the thing though — most websites are still just a '1 dimensional flow of text and pictures'. They try to disguise it with multiple columns of guff, but it's still just text and images. Sometimes a video. Sure there are web 'apps' now too, but most websites are not apps (thankfully).

>Sure there are web 'apps' now too, but most websites are not apps (thankfully).

The thing is, web apps are also just a more complex version of the same '1 dimensional flow of text and pictures,' just maybe with Canvas and a lot of javascript. There's no real difference between a web app and a document, as far as HTML/JS/CSS is concerned. The dirty secret of the whole "the web used to be documents but now it's applications" meme is that the applications are still documents.

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

#225

Earlier quoted context omitted.

What does installing a linter have to do with using a subset of a language? Just... use the constructs you're familiar with? It's not like you can "accidentally" use an ES6 class or something.

You can accidentally use == instead of ===, or even accidentally use the assignment operator instead of one of the comparison operators. You can know about for..in without knowing about hasOwnProp. You can forget to enable strict mode. The list goes on. Static analysis is universally a good thing.

[deleted]

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

#226

Earlier quoted context omitted.

> CSS works the way it does because it was created to make the kind of designs that designers wanted possible Well, not originally. Later that became a thing, yes - but all the design that was already there at that point (circa CSS 2) remained, as did the overall approach with cascading styles. A styling language designed for HTML5 today from scratch, accommodating modern use cases, would likely look a lot different.

It would probably be written in JS, maybe something like JSSS [1]. I remember playing with it when it came out and thinking it was very cool. Pity it never went anywhere. If we were going to start from scratch though, we wouldn't do HTML5, we'd use some other format. JSON maybe? 1. https://en.wikipedia.org/wiki/JavaScript_Style_Sheets

Extremely doubtful, given that many of the modern ones have been written in XML (e.g. xaml, android) and iOS went old skool with a drag/drop GUI.

No-one went pure code (because it's a massive PITA).

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

#227
post #189

Earlier quoted context omitted.

Good comment. CSS is actually pretty simple, as long as you start with the smallest elements and work up. It becomes a nightmare if you try and address everything individually. It’s not really a programming language, but a series of guidelines. I’ve seen this simplicity actually throw developers as they’re used to something much more complex and systematic. Preprocessors like SASS are great, but I wonder if they’re d…

Pixel perfect is not possible in HTML/CSS. Stop spreading this. But it is very possible to make websites look very good and inline with what was designed. But good luck making an input, button and select the same height. It's just not going to be pixel perfect. What is pixel perfect in your browser isn't in others. But what designers should now is it doesn't matter as long as it looks good for everyone.

> Pixel perfect is not possible in HTML/CSS. Stop spreading this.

It absolutely is possible—we used to do it all the time back in the table layout days—but it is not desirable. They are inherently fragile (often users can break them just by changing the default text size), and they do not adapt to different screen sizes very well.

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

#228

> 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…

Right on. Also worth mentioning in the context of deprecated web-plugins: Flash and Unity which provid(ed) sane wysiwyg layout tools (Unity's 2D stuff, being backed by scriptable components, is/was especially powerful and ergonomic)

I spent most of my frontend career in that world (and dabbling in Qt, SDL etc. for kicks), and now shifting to the web a couple years ago, it boggles my mind how horrible CSS feels compared to what I used to do with minimal scripting and a bunch of button clicking.

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

#229
post #126

1) CSS is for implementing designs; being able to use it doesn't require design sense for things like colors 2) I'm fascinated by the fact that so many of my fellow programmers - often the smartest ones - have so much trouble with CSS. I'm not sure exactly what the reason for that is, though I did write an article hoping to address it in some capacity: https://css-tricks.com/css-is-awesome/ I think part of the proble…

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 sure exactly what you are referring to, but there have been some misunderstandings regarding tables. Before CSS, -tags were there only way to control the layout, but since CSS 2, it have been possible to achieve the same kind of layout which display:table in CSS without having to abuse -tags. But there is nothing wrong with using when they are semantically appropriate.

Recently CSS have gotten display:grid which is way more powerful than table layout ever was.

Float and clear was never intended for general layout. They were invented by Netscape back in the day to allow text to float around images. Float/clear-hacks became a necessary evil in the dark age before IE supported display:table.

You cant really blame CSS for IE not supporting critical parts of the spec, since this was part a deliberate strategy by MS to "kill the web". Luckily this strategy failed and MS changed their minds.

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

#230
post #189

Earlier quoted context omitted.

Pixel perfect is not possible in HTML/CSS. Stop spreading this. But it is very possible to make websites look very good and inline with what was designed. But good luck making an input, button and select the same height. It's just not going to be pixel perfect. What is pixel perfect in your browser isn't in others. But what designers should now is it doesn't matter as long as it looks good for everyone.

The key part of my point was "as long as the designer is aware of the constraints and opportunities of the medium they’re working in." Designers coming from print often get caught out when designing for the web as they tend to think of a webpage as a fixed layout, rather than a flexible system of components. It's also important to understand where the design and development budget should be effectively spent. For exa…

> I guess it comes down to what we define as 'pixel perfect'.

When the customer hears "pixel perfect" they don't think "different on different browsers and on different OSs and on different devices", they think "the same everywhere".

Post reply on HN