Hacker News new | ask | show | jobs
by orange8 2251 days ago
> “float” and “normal” (what?) aren’t layout modes.

https://developer.mozilla.org/en-US/docs/Web/CSS/Layout_mode

> the rest didn’t exist in css until relatively recently.

Out of the 7 layout modes, only the last two came into existence recently. The point is, when CSS was being designed as a declarative, domain specific programming language, it was designed to handle EVERYTHING to do with how things appear on a browser. Even when you specify styles using JS or directly in HTML, those are simple handed over to the browsers CSS engine. The HTML engine deals with markup, while the JS engine deals with behavior. If you want to talk directly and powerfully to the CSS engine, use CSS. That what it was designed to handle: everything to do with what you SEE in a browsers screen.

> position: relative exists, yes, but it doesn’t do what you say it does. - it sets the top, left, bottom and right properties to be relative its own natural position.

If I want to position elements absolutely within a container element, one way is to have the container "position: relative" and the child elements "position: absolute". The same effect can be achieved via flex or grid layouts.

> it’s use for layout was an abuse and not what it was designed for.

I am honestly flabbergasted by this assertion. The layout of something is part of its style. See https://en.wikipedia.org/wiki/Visual_design_elements_and_pri... CSS was designed to handle all that. Layout is all about shape, space and form.

> CSS wasn’t designed for layout and it just isn’t very good at it, especially if you compare it to say, cocoa autolayout, or the flexbox model in UI frameworks that were designed to do this stuff at the start instead of having it awkwardly bolted on.

Whenever anyone dumps on CSS, HTML and JS, I simply remind them that they run the web, and the web is the most successful, open, flexible and used platform in existence. CSS is doing exactly what it was designed to do, and will outlive and outperform all those UI frameworks as it breaks out of the browser into desktop and mobile app space.

1 comments

look, i love CSS. Not dumping on it. but you have a bit of stockholme syndrome going on here. sometimes loving something means realistically looking at its flaws and limitations. and you seem to have a distorted view of history, and what a “stylesheet” is. (they existed for decades before CSS was invented, and come from the tradition of printing and writing, not design so much. they do not, generally speaking, specify layout. layout specifies layout.) from the start, browsers didn’t have a css engine. css was added later, and has never fully exposed every piece of the browser display engine. some of the browsers needed to be rewritten from scratch for this to even be possible. as for layout, from the start and for a very long rime, the position of the w3c and browser authors is that website authors shouldn’t want layout and refused to implement any layout capabilities. in their view, layout should be left up to the client, and a website author should focus only on writing plain semantic documents. they told people to stop using floats for layout because it got in the way of client decisions about layout. they have only been added grudgingly, and after the forced removal of the people who were blocking it. i for one welcome these layout capabilities, and am glad the old farts didn’t get in the way. that doesn’t mean we’re up to par with the best layout engines though.

your link makes only one reference to style: “style of shape”, and a passing reference to https://en.m.wikipedia.org/wiki/Style_guide with regard to keeping non layout elements consistent, and that page in turn, which makes no reference to layout.

> look, i love CSS. Not dumping on it. but you have a bit of stockholme syndrome going on here. sometimes loving something means realistically looking at its flaws and limitations.

I find that very hard to believe, sorry. And I could write a whole book about the flaws and limitations of CSS, and then another about its elegant power and gradual evolution over the years, but you most likely wont want to read it. You are stuck in 2002, completly fixated about the origins or the languange and what it was meant or not meant to do 20 years ago.

> and you seem to have a distorted view of history, and what a “stylesheet” is.

Right now, I am honestly not interested in the semantic meaning of the word "stylesheet" or its etymology, or the history of computing and printing. Am here to discuss CSS.

> from the start, browsers didn’t have a css engine. css was added later, and has never fully exposed every piece of the browser display engine.

Is this not obvious? A browser is made of three main engines JS, CSS and HTML. Being a GUI, all parts will influence the GUI. That does not change the fact that the CSS engines domain is what you see. The JS domain is interactivity (what you do with what you see) while HTML is about data and structure.

> some of the browsers needed to be rewritten from scratch for this to even be possible.

Can you name even one thing in computing that's over 20 years and has not changed or evolved? If your problem with CSS is that browsers had to be rewritten 20 years ago to evolve with the language, then that problem applies to every other successful language and GUI framework or system under the sun.

> website author should focus only on writing plain semantic documents. they have only been added grudgingly, and after the forced removal of the people who were blocking it.

Semantic documents are under the domain of HTML. This has nothing to do with CSS.