Live data from Hacker News

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

news.ycombinator.com

61–70 of 358 posts

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

#61
post #23

CSS is crazy. To keep my sanity, I try to avoid touching it as much as I can (I use Semantic-UI which gets me most elements with little effort), and when I have to, I try to stick to the more recent, reasonable parts. Flexbox for example is understandable and predictable.

[deleted]

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

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

CSS Media queries allow you to trivially handle different mediums (screen size, pixel density, screen-vs-print etc). It really is very very easy.

I dont agree that CSS preprocessors are evidence that the technology is incomplete. Does a c/java/golang/etc compiler mean that x86 is incomplete or somehow flawed? I would wager that most programmers wouldn't agree with that. CSS preprocessors are basically just a way of saving time and improving maintainability by "compiling" some syntactic sugar down to "raw" CSS. Same could be said with doing assembly programming vs e.g. rust/golang etc.

I agree though that in the very early days layout was hard with CSS, but then in the very early days we didn't even have devtools and XMLHttpRequests were still something mysterious and exotic. Times have changed and CSS has changed along with it. I'd recommend you try revisiting modern CSS if you have not already done so - you may be pleasantly surprised at how easy it is these days.

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

#64

I always end up having problems using css to do layout, like you mention that it's often a pain to center things. I prefer tables for a lot of things that I'm not "supposed" to use table for because the css methods don't work the same in various browsers, or at all in older ones. css for markup works fine for me. A humorous experience for me is when I look up some css concept I can't remember the details and find sit…

I won't fault you for finding tables intuitive for layout, but please stop using the actual table elements to do it. You can use normal divs with table styling for exactly the same outcome: https://caniuse.com/#feat=css-table

Semantically it does make a difference, and can impact people using accessibility technologies.

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

#65
You really want to develop a mental model of a CSS engine, so you can “run” code in your head.

This will allow you to read code and have a high chance of predicting what it will look like before running it.

Your probably not developing this mental model for some reason.

You should try to explain why you are seeing a visual result, and keep a notebook of how CSS primitives work together. For example, why are there 10 ways to vertically align, and why do they all work?

Once you collect enough primitives, you can use them together to design a layout.

You could try developing your own css layout engine which would force you to understand the rules.

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

#66
CSS isn't hard. It's design is broken on a few things which makes it look more complicated than it should.

I've done web for 20 years and I still Google around when it comes to aligning things vertically centered and I sometimes fall back to using tables for layout because it's still the most stable way to keep stuff at where it should be.

And of course the way you need to declare in a very redundant way for selectors on multiple elements is annoying but we have at least sass and my preference is using stylus (combined with pug) which removes a lot of those unnecessary declarations go away with the ability to define variables in 1 file and use it all over.

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

#67

I work as a frontend architect and UX lead (yes, it's tiring), and you're encountering a common problem. Javascript is logical (sort of...), and a lot like learning math. It's fairly easy to validate your output. It works well with the logical side of your brain. Learning CSS is a lot like learning English. There's the basic grammar, but also tons of edge cases, dialects, and straight up absurd rules (Buffalo buffalo…

A layout engine and design are two entirely different concepts. CSS has nothing to do with design. It is the tool used to implement the design and there are loads of other layout tools out there that don't have CSS's infuriating quirks. On the flip side, they usually have steep learning curves because they are strict. For a long time, until less than a decade ago, designers knew nothing about CSS. They'd do a design…

> Some (unlucky) programmers entire job was turning PSDs into HTML and CSS.

That was my entry into programming many years ago. But I wouldn't call it unlucky - early web devs like me (we didn't really call ourselves programmers back then) had front-row seats at the beginning of a revolution, and it certainly was entertaining to watch and be part of.

> CSS has nothing to do with design

CSS works the way it does because it was created to make the kind of designs that designers wanted possible. It has everything to do with graphic design. All the web designers I knew back in the early days knew some HTML and CSS and we'd often discuss possibilities and limitations of browsers and standards, and how to work around issues. They didn't just lob PSDs over the partition to the devs - there was an active dialogue and they knew their stuff.

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

#68
It sounds like layout is your primary problem (as it is most people's). You should view (the layout-specific parts of CSS) as a layout description language, which is a class of languages you've never worked with before, and so something that requires significantly more time investment than just learning a new syntax (e.g. JavaScript). My guess is you haven't put in that amount of focused study, so naturally it doesn't click for you.

This is not to say CSS doesn't deserve any blame--it's a bad layout description language, as evidenced in part by the fact that the recent grid+flexbox additions are much better (where supported) than old-school CSS.

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

#69

I work as a frontend architect and UX lead (yes, it's tiring), and you're encountering a common problem. Javascript is logical (sort of...), and a lot like learning math. It's fairly easy to validate your output. It works well with the logical side of your brain. Learning CSS is a lot like learning English. There's the basic grammar, but also tons of edge cases, dialects, and straight up absurd rules (Buffalo buffalo…

I think there's edge cases, dialects, and straight-up absurd rules in JS too.

I don't think CSS is any less logical... but some might not be use to _declarative_ languages like CSS is?

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

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

CSS Media queries allow you to trivially handle different mediums (screen size, pixel density, screen-vs-print etc). It really is very very easy. I dont agree that CSS preprocessors are evidence that the technology is incomplete. Does a c/java/golang/etc compiler mean that x86 is incomplete or somehow flawed? I would wager that most programmers wouldn't agree with that. CSS preprocessors are basically just a way of s…

> CSS Media queries allow you to trivially handle different mediums (screen size, pixel density, screen-vs-print etc). It really is very very easy.

Disagree. CSS media queries allow you to identify different media, just like uname(2) allows you to identify the platform you‘re running on. Handling all the aspect ratios, resolutions, capabilities, bugs, idiosyncracies of the current device or modus operandi is not at all trivial, especially if you don’t want to design for each situation from scratch.

Post reply on HN