Live data from Hacker News

Why is CSS the way it is?

increment.com

61–70 of 173 posts

Re: Why is CSS the way it is?

#61
post #5

I have a weird relationship regarding CSS: I kinda like it (although some things could be even a bit more powerful), yet everybody I meet tells me how horrible and hard etc it is. I never had that feeling at all, not even back when I started using it as a teenager to customise my MySpace site. I cursed at how hard common things like centering a image within a div were, I cursed at the purposeful and ignorant incompat…

[deleted]

Re: Why is CSS the way it is?

#62
post #49

IMHO this article inadvertently shows why people hated CSS at the start. He spends a lot of time talking about color space conversions that few developers care about and Unicode filtering that even fewer people know about but glosses over basic layout by mentioning how floats allow for better inline images. It’s like the designers didn’t even think about layout because that problem was already solved with HTML tables…

Heck, I would have been happy to have had flexbox day one. I think flexbox covers 'most' folks layout needs fairly easily, and you can learn it fairly easily and get a lot out of even basic flexbox knowledge. Tables for layout were horrific. We talk about div spam these days but at least they're all just divs and divs follow divs rules. Unlike divs table, tr, td are all different and don't follow the same rules. And…

I often use grids when flex would do just to take advantage of the grid gap features. Once the more general gap feature lands in most browsers I’ll probably start using flex more again.

Re: Why is CSS the way it is?

#63

Earlier quoted context omitted.

Yes, Flash was a great tool to create stuff. (I only used it in Macromedia times) This however also lead to an abuse and for a while you had websites, fully in flash which broke so many things (deep linking/bookamrks, browser history, etc.) combined with unintuitive navigation and slowness due to animations ... plain overuse of an otherwise good technology.

> broke so many things (deep linking/bookamrks, browser history, etc.) Truly we have failed to learn from past mistakes.

Modern JavaScript frameworks have support for this and a result of Flash's experience is that browsers have specific APIs for that ... however: each new generation of developers has to learn :)

Re: Why is CSS the way it is?

#64
post #33

Earlier quoted context omitted.

Flash websites were awesome. the player needed work, but for end users there web was a much more interesting and diverse place

Unless you used a screen reader

True, although if Flash had stuck around long enough (i.e. if iPhone hadn't signed it's death warrant) I'm sure eventually we could have come up with a solution for a11y.

Most of the flash sites that I really remember consuming were actually very simple documents that relied on flash for presentation, so it would be easy to provide a screen reader friendly version of the content.

Also a lot of flash content was cartoons and games which don't lend themselves to screen readers anyway.

Re: Why is CSS the way it is?

#65
post #5

I have a weird relationship regarding CSS: I kinda like it (although some things could be even a bit more powerful), yet everybody I meet tells me how horrible and hard etc it is. I never had that feeling at all, not even back when I started using it as a teenager to customise my MySpace site. I cursed at how hard common things like centering a image within a div were, I cursed at the purposeful and ignorant incompat…

Give me better composition options with css. I will love it. Until then, it is a toxic relationship. I have to use a preprocessor for that and it increases the time to see feedback from the browser.

Functional css totally changed my perspective on css. In the same way that react made me enjoy writing JS again Tailwind made me enjoy styling with css again. All that nasty coupling disappears.

Re: Why is CSS the way it is?

#66
post #60

The biggest issue with CSS I think for many is the emergent complexity from the interaction of different properties. Especially those inherited through the cascade. Much of this emergent complexity is not always consistent cross-browser. Additionally, there are often many ways to accomplish the same result but fully understanding the implications of certain approaches over others is also a headache at times. Speaking…

The biggest issue with CSS I think for many is.. ..that they haven't looked at it for years and assume it's still as hard to use as it was when it was new. In any discussion about CSS someone will eventually post that "vertical and horizontal centring is really hard, and that's why CSS is terrible"[1], and all it shows is that their skills are out of date. [1] Seriously, it's as easy as "display: grid; place-items: c…

I’m no expert here, but I think the model of always adding new syntax doesn’t help people realize that CSS has gotten so much better.

Re: Why is CSS the way it is?

#67

Earlier quoted context omitted.

> it is not difficult to understand in terms of conceptual understanding So what is your point? What you lack is motivation to make things pretty so it's not CSS's fault :)

My point is that there's nothing in CSS that's exceedingly difficult to understand once you sit down to learn it - it's that you're often sitting down to learn things that are entirely idiosyncratic to CSS and act as impediments to creating anything beautiful. I could abandon CSS and use SVG to create prettier things pretty quickly, because although SVG has some gnarly parts, programmatically manipulated it makes muc…

> Then I'm dealing with the interaction of specific elements and document flow and everything is liable to fall apart the second some mismatch between my mental model of layouts and CSS's actual model occurs

Here lies the problem. If you fix your mental model, then your layout won't fall apart.

It's the same as in any other language. Haskell doesn't match my mental model, but it's not the programming language's fault.

Re: Why is CSS the way it is?

#68
One thing I've been realizing is that layout and style are two different thing. Layout I almost always want done on the parent element, and style, I almost always want done on the child element.

For example, I probably always want h1 elements to have the same font/weight/size. That's style, and should be defined on the h1.

In contrast, the h1 within a blog post may be positioned very differently from the h1 within a video page, so I'd want to define that in the blog post and video page styles, respectively.

Of course, where this gets complicated, is that there's not always a clear boundary between style and layout. For example, I might always want the same amount of space under the h1 between the h1 and the content it titles (style?) but the top/left/right spacing is probably more dependent on the context (layout?). There are some hard to communicate tradeoffs here.

Re: Why is CSS the way it is?

#69
post #49

Earlier quoted context omitted.

Heck, I would have been happy to have had flexbox day one. I think flexbox covers 'most' folks layout needs fairly easily, and you can learn it fairly easily and get a lot out of even basic flexbox knowledge. Tables for layout were horrific. We talk about div spam these days but at least they're all just divs and divs follow divs rules. Unlike divs table, tr, td are all different and don't follow the same rules. And…

I often use grids when flex would do just to take advantage of the grid gap features. Once the more general gap feature lands in most browsers I’ll probably start using flex more again.

Yeah there's reason to use grids, particularly if you're comfortable with them. I like to start with flexbox if I don't know where things are going / I'll need grid and .. surprisingly I rarely have to move on to grid.

Granted I'm mostly working on business apps, not a lot of complexity there layout wise, flexbox works great for that, and it's not a heavy lift for someone to learn it.

Re: Why is CSS the way it is?

#70
post #5

I have a weird relationship regarding CSS: I kinda like it (although some things could be even a bit more powerful), yet everybody I meet tells me how horrible and hard etc it is. I never had that feeling at all, not even back when I started using it as a teenager to customise my MySpace site. I cursed at how hard common things like centering a image within a div were, I cursed at the purposeful and ignorant incompat…

You're correct about not being able to target parent selectors without some JS intervention - BUT - if you avoid any property declarations on your default img elements you can achieve what you desire.

Live demo: https://codepen.io/bradleytaunt/pen/LYGapao

Post reply on HN