Live data from Hacker News

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

news.ycombinator.com

251–260 of 358 posts

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

#251
post #184

Earlier quoted context omitted.

That’s because the rendering engines in email software are crap, not due to a deficiency in CSS - I think Outlook still uses Word’s HTML renderer and even Gmail doesn’t support everything.

In all fairness that's probably a good thing. God forbid if emails today were like the rest of the web, hijacking the scrollbar, constant popups to register, like and subscribe. I like my emails like I like my actual mail; text and maybe the odd image.

> hijacking the scrollbar, constant popups to register, like and subscribe.

Those are JS related, I don't think anyone is asking for renderers to allow that. But proper CSS support would be nice.

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

#252
post #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? Eve…

The worst part for me is that it's one of the few places I end up having to hack my hacks because I find out that Firefox does something wildly different from Chrome so the fix I just made to Firefox made it better but broke something else. It feels just as annoying and opaque now as when I was doing CSS hacks for Netscape navigator vs IE. The other thing that frustrated me about CSS and continues to this day is the lack of permanence of a working layout. That is one of the things that really separates the backend from the front end mindset for me, the back end can be done forever but the front end will have to change to fix something unknown in the future

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

#253
post #229

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

>Before CSS, -tags were there only way to control the layout //

As an historical aside: that's not quite true to my recollection.

p-elements had width, height (and possibly other attributes, margin, border?). And empty

, hr, br(?), were used for rudimentary layout? Then there was color, bgcolor attributes; and font tags. Not sure when came out?

This https://www.w3.org/Style/CSS20/history.html is probably much better than my recollection. I started making webpages/email-circulars about 1994-95.

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

#255
post #142

Earlier quoted context omitted.

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

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

> What's the advantage?

The same content reflows to different 2D spaces

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

#256

First of all, CSS is t like any programming language. It’s a cascade of properties that is tightly coupled to the tree-like nature of HTML. You don’t ‘understand’ CSS on it’s own; it must be in tandem with suitable HTML. Secondly, the visual aspects of design (colours, fonts, layout) have got nothing to do with your grasp of CSS. I am not a designer and really struggle to make pages look good without a professional’s…

Seconding the recommendation for Tailwind. I know functional css is controversial, but Tailwind isn't dogmatic about it. Sensible defaults for colors, fonts, padding, etc. And unlike Bootstrap, when you use Tailwind, you're actually learning css instead of a framework. I feel like my css is a little better since I started using Tailwind.

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

#257

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…

> As your focus goes through any content, it necessarily follows a 1D path

No. Not at all. Almost never. Your brain is a chiefly parallel processing device, no matter how much you delude yourself that "you read text in the order it was written" and other such nonsense...

It's widely known that this is not even how people read text. Even when you listen to music, and nothing is more 1D than sound, your brain chops it up and rearranges in multiple concurrent variants trying to "do the shazam thing" of identifying what else it may be even a bit similar to even if you don't realize it...

"Following a 1D path" through content is what you do when you either want (1) to reliably communicate at the lowest imaginable common denominator with people with unknown and presumed low skill and intelligence (eg. "talk to a customer" or "talk to the bank teller") or with people so mentally different from you that they are close to being a different species (eg. "talk to an accountant or lawyer" or "send a binary encoded message to maybe be received and decoded by an alien civilization"), or (2) you actually want to force a particular interpretation of the sequence and causality of things to people (eg. "explaining history to people" or "telling an educational story" or "manipulating people" or... "selling stuff to people").

All the other communication, and more like the only part of interpersonal communication that I find interesting is non sequential, it's about working with information that can be rearranged in multiple equally valid sequences and interpretable in multiple possible causality graphs. Think maps and painting. Or a textual description of a stack of maps etc.. Or computer code as it actually gets executed on an even slightly parallel machine (not "as it stays written code in a text file", that's also a "lowest common denominator representation" bc human and computer brains are so different).

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

#258
I can only assume that you're trying to run before you can walk. Remember that you're just defining a set of layout rules. You're not giving the browser specific instructions to follow. It seems that there's the temptation to assume that CSS is easy and simple, because it's for the web and isn't a proper programming language.

That is clearly not true. CSS describes a complex set of interactions which evolved over many years. You'll have to refer to MDN, experiment in your browser dev tools, etc.

Start in small and isolated chunks. Open a codepen with just a couple of divs and work out how their layout interacts.

I firmly believe that you can write beautiful CSS. Your list of languages shows that you are clearly interested in learning, and in expressing your needs in varied ways.

As an aside, I would recommend having a design on paper/on screen to implement before starting to write your CSS. Until you become relatively fluent with it, I think CSS relatively counter-productive as a design tool. Thinking about the target result as a separate step from implementing that result is going to be a much better approach.

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

#259
CSS is not hard, but it's certainly unusual compared to programming in any other language because you're dealing with the DOM. HTML was originally designed to display simple text documents, not fully fledged single page responsive and progressive web apps. My single piece of advice is to master the top CSS properties, relative/absolute/fixed positioning, and grids & flexbox for layout. CSS has come a long way and it's 10x easier to layout content compared to just 10 years ago.

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

#260
post #117

I can't understand CSS either. For Elm you can bypass that headache with this library; https://package.elm-lang.org/packages/mdgriffith/elm-ui/late...

I'm quite interested in this library. Have you used it? What did you like and not like about it?

I am using Elm-UI. I haven't written any CSS or any raw HTML in my project. The elm-ui layout model works very well. The `explain` attribute is a life saver in more complex layouts. There is much to love and very little to hate. I have been struggling a bit with `width fill` on rows and wrapping of blocks of text. But, these inconveniences are almost insignificant compared to the complexity of CSS. Elm-ui is well worth trying out.
Post reply on HN