Live data from Hacker News

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

news.ycombinator.com

231–240 of 358 posts

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

#231

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

I'm glad to read I'm not the only one struggling with it. It's not as bad as with the OP; I can get stuff done in CSS. But any non-trivial layout always requires a lot of trial and error: does this need to float? Does inline-block work better? Now there's flex layout on top of that. Do I need relative or absolute positioning for this thing? Do I need padding or margin here? And why does my margin not do anything?

Every time I think I finally understand it, I run into a situation where it doesn't do what I expect. And then there's hacks with negative margins and that sort of stuff, where it feels like CSS needs to be wrangled into doing something it doesn't want.

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

#232
post #86

CSS is not as difficult as many people think. I believe part of the reason why developers have trouble with CSS is that they don’t ever try to write it from scratch. A lot of web development tutorials/courses/bootcamps often go in depth on JS and maybe HTML but always just slap in CSS frameworks to make things look nice as an afterthought. I remember the first project I worked on as a web developer was to update the…

No, as someone who's struggled, and seen other programmers struggle, with CSS way before bootstrap was released I can assure you this isn't true.

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

#233
Whenever this subject crops up, I'm inclined to just answer "Yeah, it's just you", at the risk of that coming off as too harsh.

I really like CSS and it's where I got my start, and used it for a long time, often to make up for not knowing JavaScript.

I don't think CSS is an art thing. I think CSS is pretty simple, but requires an understanding of how CSS works and how browser layouts wotk.

Without that, you're going to have a hard time, but I can't really think of a language where that isn't true, either.

Sometimes I feel like this is the result of people undervaluing CSS, because they "just want to make a colored box" or whatever, but fail to view it as its own language, with its own ecosystem and considerations, placing undue expectations on its simplicity.

If I were to "just make a program" in C, without any knowledge or consideration for how Windows works, how stacks, heaps, memory, and pointers work, and how C works, then I'm gonna have a bad time, and the same goes for CSS, imo.

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

#234
Yes CSS is too damn hard.

Too hard to learn? No. Too hard to use? No. Too hard to do elegantly? No.

It's too hard because it doesn't need to be nearly as hard as it is. Advanced layout can be done using techniques like pivot, relative anchoring and alignment, and lots of other approaches that CSS lacks.

It's too hard because what is there is broken. Even the new stuff (try to select a row in an auto-adjusting grid. You can't yet, and the powers that be will eventually fix that... which is ridiculous for a modern release)

It's too hard because it's neither how designers think, nor how programmers think, nor how users think. So you need to write it in some weird hodgepodge that accounts for none of those and all of those.

It's also too hard because due to the difficulty it takes a lot of time to get good at, and so we as non-CSS gurus don't invest the time we need to digest it... because why would we when it shouldn't require that sort of investment?

At the end of the day it's almost like going to your neighbor's house but some committee forces you to walk in zigzags and on your hands. It'll get you there, and you will become so good in the process you could work in a circus, but it's an unnecessary pain when you just want to drop off a cup of milk.

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

#235
post #87

I'd recommend spending some dedicated time learning about layout, not leaning on a framework. CSS layout is largely about the relationship between elements. Instead of looking at it as "I want this element on the right," try to see the relationships between elements. What's the group of elements, and what causes them to be where they are? (Generally, complex layouts are nothing more than nested groups of elements.) O…

That's really interesting. I'm also firmly in the space of finding CSS layout inscrutable (CSS styling is fine). I'd concluded that the issue is precisely the lack of peer-to-peer relationship constructs. Everything seemed based on 2 constructs:

1. Flowing 1D content (text) into a 2D space

2. Hierarchical relationships, i.e. positioning children with respect to parents.

I haven't looked deeply into flexbox or grid. My initial skim suggests they're both still fundamentally hierarchical. I'll take another look now given your comments.

I'll freely admit I haven't invested a lot of time trying to get to grips with the more recent constructs (flex/grid). I would say my initial forays were difficult and frustrating. CSS layout seems (seemed?) the antithesis of the maxim "make the simple things easy and the hard things possible".

As a counterpoint: back in the midst of time, there was a cross-platform UI toolkit called Galaxy. It only had 2 layout constructs: springs and struts. Springs defined a proportional layout between components (so would stretch/compress), struts defined a static relationship. It was remarkably simple to define layouts using just those two concepts.

The web is clearly a more complicated space than conventional, thick client apps that only ran on the desktop. Responsiveness is a much bigger challenge now. Nevetheless, it seems to me that the key construct lacking in CSS is the ability to specify peer to peer relationships among elements - without needing to create a whole cruft of container components.

You've incentivised me to give flex/grid another look. I remain healthily sceptical, but thanks for the prompt.

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

#236
post #214

Earlier quoted context omitted.

Don't tell me you can't verb a noun in English English? "police police police police" - please...

FWIW I'm an ESL speaker from a non-English speaking country and despite having had endless exposure to (mostly American and British) English since a young age, I've never encountered the verb form of "buffalo" outside that one sentence. It's an informal North American idiom and by international standards apparently a fairly obscure one. Policing OTOH seems to be a fairly widespread verb form with a clearly understood…

It’s extremely obscure as a verb in North America too, fwiw.

Buffalo the city was probably better known 150 years ago, when it was an economic powerhouse as one of the end points of what’s still the second most famous canal in the Western Hemisphere. Afterward it continued to be a significant industrial center until the decline of manufacturing turned the Great Lakes region into part of the “Rust Belt” in the past 50 years. Most Americans probably know of it these days because it still hosts an American football team.

Anyway, the point isn’t that that’s a common sentence. It’s that it’s a grammatical one.

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

#237
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 itself isn't a bad idea but less, scss etc. showed that it was lacking some features you desperately want and in the meantime just styling the web with "a little CSS" is not enough anymore.

You have a shitload of display sizes to support on the other hand and strange behaving browsers which aren't truly standardized on the other. That makes adjusting your CSS to all of these a pain in the ass even if you like fiddling around with styling (as I basically do).

I don't want to adjust my margins, paddings and fonts and then restart from scratch because f Apple decided they will do everything in Safari completely different from the rest of the browsers just to show how special they are.

I'm also sick of building selenium grids with a mac mini in them just to also test this piece of ... "ingenuity" ;-)

So nowadays I just go with a framework with sane defaults and no-hassle usability and when I need something special I ask people who don't do anything but CSS the whole day.

Without more standardization it's not a domain you'll be great at when you don't specialize in it - which means you got to invest a lot of time to master it.

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

#238
post #230

Earlier quoted context omitted.

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

Sometimes the target is a known browser version on a known OS (eg. intranet sites). Those are a lot simpler and (arguably) fun to make.

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

#239

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…

This one dimensional curve of focus throughout a 2D page will be different on each viewing and for different people.

That's why the 2D layout is important because it can help assist or guide the creation of this path. For many pages there is no fixed "proper" path through the content even though the DOM is necessarily in some order.

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

#240
post #230

Earlier quoted context omitted.

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

That should be one of the first conversations had with a client. It's all about managing expectations.

During the pitch meeting we'd point at the big TV in the meeting room, their laptop and smartphones and (maybe) watch, and explain that while we could make their site look great on everything, it wouldn't look the same.

Post reply on HN