Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
The State of CSS 2019 (stateofcss.com)
98 points by mhr_online on June 17, 2019 | hide | past | favorite | 65 comments


> CSS on the other hand has always been the studious, well-behaved kid who always stays polite and never makes a rash decision

This is such a strange picture to paint!

CSS has always been the dim-witted kid. For a long time, it couldn't do math. For a long time, it couldn't have varibles. For a long time, it did not have a reasonable syntax for page layout. Its rules have global visibility (if we don't consider shadow DOM). And those vendor prefixes! This is one hell of a kid!


remember when CSS couldn't center horizontally in a reasonable way? Pepperidge Farm remembers.


For a long time, it didn't need any of those things. It's only been a recent need for marketing, mainly.


Not even close. Marketing has lead to some absurd uses of CSS but it's more about adaptive/responsive design.

When you need to handle an almost unlimited range of screen sizes having your visual system able to handle a little math is critical.


First there was marketing. Then there was adaptive design. And variables are new compared to almost everything else.


There's a CSS & FP Working Group note that listed variables--or more specifically, symbolic constants--as a proposed future extension to CSS2 back in 1998,[0] and I'd assume that there are even earlier discussions on the matter as well. The idea of using variables in CSS isn't new by any means. If you read this 2008 essay by Bert Bos[1] against extending CSS to include variables Bos makes a really intriguing comment that "macros help for authors, not for the semantic Web" in his conclusion.

Perhaps I'm reading into things, but it seems rather illuminative in terms of understanding how at least some key figures in the development of CSS may have viewed things. If you consider CSS in terms of two distinct audiences--authors/maintainers and users who consume CSS-styled documents--then at least some of the decisions with the CSS specifications seem to make a bit more sense. In which case, it's not so much that CSS didn't need the listed functionality as it is that other goals for the specifications were prioritized over the benefits of variables and other functionality. Reusability, modularity, and simplicity were some of the main priorities. They still are, but I think we've seen a redefinition of those terms with the direction front-end development has taken in the past decade; I also think that improvements in the uniformization of browser implementations and development of better debugging tools has helped erase some of the concerns given in the essay.

0. https://www.w3.org/TR/NOTE-CSS-potential#id05684046681

1. https://www.w3.org/People/Bos/CSS-variables


> other goals for the specifications were prioritized over the benefits of variables and other functionality.

That's what I said. Until marketing forces clamored for such things, other less interesting things that weren't sparkles and lollipops took precedence.


There's a missing feature. Look at a css page and know how the site will behave. Every programing language you look at code (if well written) and u know what it will do. In css you know what are the attributes set but it doesn't really tell you what is going you happen. That's the only thing I don't like in css.


This is the killer reason why I hate doing anything with CSS. There's close to zero predictability.

CSS has no isolation / encapsulation, no control flow and no local state. Every line of code can modify and affect every other line. And even then, what happens is then dependent on an independently defined DOM object.

Yes, it's possible to write CSS in a way that helps ease the problems that the missing features above cause, but that's working harder to work around the language.

The raison d'etre of CSS, "style independently of the semantic document" is a failed project. It works for DOM trees that can be legitimately considered documents but fails horribly for what can be considered 'applications'. For that reason, I think an overhaul of web document styling is much needed.

The purists will cry that most of what is delivered on the web are "applications" and not "documents", especially when it comes to the morning news, but pretending that isn't the case isn't helpful.


> It works for DOM trees that can be legitimately considered documents

That's because this is what the web was built for. But then everyone wanted to turn it into an application platform by building on top of a document model. Of course CSS was designed to style documents.


Many people heard your pain so this is why in Vue.js CSS is isolated, while in react you can use styled components for encapsulation, sort of.


Maybe web tech for applications is the failed project, not the CSS.


What layout system/language would work in a readable manner? To me layout is basically a way to express a set of constraints which can be sometimes contradictory. In CSS a problem rises because the system will always manage to resolve them, somehow, and there are no warnings. LaTeX or AutoLayout will help you write an unambiguous layout, but they are still inscrutable at a glance.


> Every programing language you look at

Isn't the point of CSS that it's not a programming language? It's just a list of properties, after all.


CSS is a list of declarations. There is nothing esoteric about it.

You can read it from top to bottom and understand what the defined styles will look like when they are rendered.

If your naming is done correctly and your files are separated by features, there is no reason why you can't understand and visualize everything that is defined.


Unsurprisingly Stylus is one of the preprocessors that people want to avoid the most (beating less by 1% in user satisfaction). The preprocessor is very apathetic to what style you use - it's the antithesis of a linter. Want to use a semicolon on this line, and not one on the next? Go for it! Not the best when you want to write something production worthy.

That said I've found it phenomenal for prototyping, simple codepen examples, and teaching css. I run the prototyping efforts at Atlassian and I've built a large amount of code prototyping tools focused on allowing designers to quickly build something out. The standard template I give to designers and students uses stylus by default because it allows them to make mistakes. People who are unfamiliar with code feel defeated when a small syntax error was the one thing holding them back - it makes them question their understanding of the intention of what they wrote, even when the meaning of what they had was correct. Stylus fixes so many of these things for me. I'd highly recommend doing any of your exploratory phases in Stylus.


> Want to use a semicolon on this line, and not one on the next? Go for it! Not the best when you want to write something production worthy.

What do semicolons - or braces, for that matter - have to do with production worthiness? Style inconsistencies do not cause bugs. Poor CSS rules do.


Inconsistencies in the source file do not affect production worthiness in the moment, but they do affect maintainability down the line. If for instance your team wants to move to a new css preprocessor that's the next big thing in 10 years, a consistent style means you can programatically convert to the new syntax. Or maybe there's a tool that can help you write better css and detect where rules are unused -variable syntax will be sand in the gears for something like that. Mishmoshed syntax everywhere is a nightmare for programatic accessibility, though is excellent for simply trying things out.

I love stylus, don't get me wrong. I use it for all my projects - even in production. But if I were the head engineer of say, google.com, I wouldn't allow it in production for a codebase that large due to the potential for problems down the line.


I wouldn't pick Stylus for a new project, but you can use it with a linter like Stylint (https://github.com/SimenB/stylint) to enforce stricter conventions. Totally agree with you on the importance of consistency for maintainability (where it can be applied automatically with tools).


Clear and consistent code formatting guidelines (and ideally automatic formatting for this) is also great for reducing the thought required in formatting code you push while reducing noise and code formatting debates in code reviews.


Can’t second this enough


The HTML in the report tells me as much about the state of CSS as what is in the report.

Sure a lot of people know lots of clever CSS things, but are we over-complicating things and forgetting the basics of HTML?

This report does not use HTML properly. It is a sea of divs which is all well and good for CSS but not what this whole thing is ultimately about.

The document structure has a main element but this is in the wrong place. According to the HTML spec the main element should be directly below the body element with no extra div wrappers.

Then the page has one nav element. Beyond that it uses none of the sensible HTML5 elements for the content. Nothing is broken down into sections, articles and asides. Graphs are not in figures.

These elements are important, otherwise we might as well just give up and just post images with imagemaps.

Surely some content on the report must be a 'header' or part of what you might call a 'footer'?

I don't get this complacency when it comes to writing HTML, why everything always has to be in a div when the spec says you should only being divs when there are no better elements.

Since this report is entirely written in div soup with one nav element and one badly placed main, they don't know HTML so why should I take seriously what the report says about CSS? It is going to be the same cargo cult stuff.


It looks like a <main> element is allowed to have div ancestors: https://html.spec.whatwg.org/multipage/grouping-content.html...


True, you can have as many divs as you want. But it can't be in a more sensible element and there is no good reason with today's CSS layout to want to put it in untold wrappers. Maybe it is a react thing where everything has to be in div wrappers.

Anyway, if the spec matters more than the toolchain it should not be anywhere but directly under the body element.


The comment you replied to points out that "main" can be inside a div according to the spec.

Also, React doesn't require the wrappers.


It was built with React, so they don't really care about how the actual HTML elements are laid out.


That's no excuse. React has no opinions about which elements nest within which others. Since React 16, it doesn't even force unnecessary wrapper elements thanks to the inclusion of `React.fragment`.


I just can't take this website serious. Is it a parody or a joke? It looks awful and it doesn't even fit on mobile (https://i.imgur.com/6GD8yfD.png && https://i.imgur.com/lxs0gVG.png)

What happened to keeping it simple? http://motherfuckingwebsite.com/ or http://bettermotherfuckingwebsite.com/


Won't comment about whether it looks awful or not, but in terms of the mobile experience it seems to work fine for me on my OnePlus 6T with Firefox Focus, and subsequent tests on desktop using the Responsive Design Mode in Firefox with various size also worked as expected.


I mean, even before getting to not responsive the choice of colours is annoying: two not so distant shades of blue, a joy to watch on mobile, especially with the blur shadow added to headers


There is such a thing as a bug or oversight and you found one. No need to get carried away w/ the blame game. Lots of other devices are experiencing this site just fine.


It looks pretty perfect on mobile for me on Safari on iOS


> and it doesn't even fit on mobile

It loaded fine for me... Firefox Focus on OnePlus 6T


Works fine in Mozilla's Reference Browser on Honor 7X.


Well.. as a developer who probably works more with CSS and HTML than anything else, I really enjoyed this report. I found the visualizations and even the overall design provocative, and I even learned a few things in the process (overscroll-behavior?!)


If this was a photo pasted into word that was then printed and faxed it wouldn’t make the content any less meaningful.

Thanks for sharing the interesting results into various usages of css; I learnt about some new things, and found the usage of different things (especially units!) very interesting.

As an aside, the site worked great for me on mobile. Some images were big and slightly awkward to scroll around, but worked just fine.


Why is my laptop suddenly cooking when I'm just reading that page?


I'm curious about the 8% of people using cm as a unit in css...


The same people doing print stylesheets?


Of course. I thought it was a lost art but it makes sense.


Doing metric print stylesheets.


Even more absurd than metric is those using imperial units.


While I prefer millimeters, I do find using measures of physical length useful when mocking up paper forms in CSS.


> JavaScript has developed a bit of a reputation as the angry, rebellious teenager going through a new phase every year and telling you you're just too old to understand.

Couldn't agree more.

I imagine one of the many reasons is because CSS features can't be transpiled but many of JS can.


Given the results on layout tools:

Grid - 54.5% have used it, 43.2% heard of it, but haven't used it

Flexbox - 94.4% have used it, 4.64% heard of it, but haven't used it

...I wonder how the adoption of CSS grid will play out over time. Are people comfortable enough with flexbox that they don't feel the need to use CSS grid?


I think the most offensive thing here is that 6.2% of people use inches as a unit of measure in their css.

The thought of 𝚋𝚘𝚛𝚍𝚎𝚛: 𝟶.𝟸𝚒𝚗 𝚋𝚕𝚊𝚌𝚔; sitting in someone's css is terrifying.


As someone who hasn't done CSS in a while, with a 4K monitor and the knowledge how old pixel-based desktop apps look on it (VERY small), what's wrong with inches?

From my own non-CSS based graphics experience, the only problem with layouts specified in absolute sizes is that small lines look really bad on standard (<100dpi) monitors if not aligned to the physical screen pixels. (Not saying that's not bad!)


Inches in css aren't in any way related to physical inches. CSS has no knowledge of your physical screen dimensions. Rather an inch was defined early on in the history of css as "1 inch in pixels of a 17 inch screen at 1280x1024 resolution" This happens to be 96.42 pixels, which rounded down to 96. So not only is it an obscure unit, it's also a misleading one.

On your 4k monitor 96 pixels is more than likely not an inch (unless your monitor is slightly over 42 inches), so it wont solve your small app problem in any form, it will just make things more obscure.

In addition to this, you'll also end up with many subpixel values. While this wont matter for 𝚋𝚘𝚛𝚍𝚎𝚛 in the example I posted above (as border always snaps to the nearest dp unit), it will create blurry effects on lower DPI screens for other css rules that do respect subpixel values (i.e. 𝚋𝚘𝚡-𝚜𝚑𝚊𝚍𝚘𝚠: 𝟶 𝟶 𝟶 𝟶.𝟸𝚒𝚗 #𝟶𝟶𝟶; will create a blurred border effect).


That said, Mozilla did use to have the experimental `mozmm` unit that attempted to accurate represent the millimetre. However it was removed a few versions back.


> On your 4k monitor 96 pixels is more than likely not an inch (unless your monitor is slightly over 42 inches)

That's good to know. My 4k monitor, coincidentally, is about 40.5 inches, so CSS inches are displayed almost correctly.


One other reason is probably because inches is not a universal unit of measurement for computer graphic. Especially for someone who comes from country where inch is never used (like me), you need to mentally calculate the value to something more familiar.


On the web, inches don't actually work based on physical inches, they're just another pixel measurement. But assuming they did work on physical inches, they still wouldn't capture how close the device was going to be to your face, what the pixel density/brightness was, anything like that.

For the most part, use percentage, `em`, or `rem`. This is based off the the font size, which is more accessible (your app will still look good if someone with poor eyesight changes the font size). It'll also mean your app works well with fractional scaling out of the box. I believe that most desktop-level graphics frameworks like GTK support `em` units. At the very least, on the web, avoid pixel measurement in most cases.

It turns out that device font-size is a good measurement to capture most of the variable parts of user experience -- a pixel dense device that's held close to your eyes will have a small font size, a high resolution monitor that's farther away will have a larger font size -- and `em` will work great in both cases.


> But assuming they did work on physical inches, they still wouldn't capture how close the device was going to be to your face

At least the inch is a unit whose physical size, by the name, you could assume to not change when screen resolution changes. And also, DPI (or just the physical monitor size) is usually something the user can configure in the operating system - to account for viewing distance or personal preferences.


I've used inches when doing print-based CSS, although I'd be surprised if that accounts for all of it.


I'm dying to know: what's wrong with inches in CSS?


I'm gonna guess that they have very little to do with inches in the real world, and will in fact display at different lengths on different screens.


That's true, but that issue isn't specific to CSS inches. Pixels aren't pixels, points aren't points, etc.

It's not even an HTML/browser issue. There's a general problem with knowing in software the real-life physical size or length of something displayed on screen. The calibration information available isn't generally reliable, though I think people are paying more attention these days with the growing interest in AR.


It's likely being used for _print_ css.


That's 19.2px.


Kinda all you need to know about the state of CSS in 2019: the menu’s bottom items cannot be accessed on mobile Safari. Also: the scrolling is awkward/broken.


If half the effort put into shitting on CSS went instead to improving it, maybe it would be perfect by now. The requirements of CSS as a language are insanely complicated - open source, implemented by different browsers, on all different devices, for applications doing a huge variety of things, working with 20 years of legacy code. I defy anyone to explain how they would do it better and still satisfy all the constraints.


> If half the effort put into shitting on CSS went instead to improving it, maybe it would be perfect by now.

More than half of effort is put into improving it. Too little reaches the final stages.

> I defy anyone to explain how they would do it better and still satisfy all the constraints.

I had a rant or two about this in the past: https://medium.com/@dmitriid/ok-w3c-and-whatwg-dont-die-but-... :)

CSS and HTML still pretend they are just text and images on a paper (or a 2D plane). And this hasn't been the case for over 10 years. As a layout engine CSS still has less capabilities than Delphi or Qt from early 2000.


And you can't run Delphi or QT based projects on Windows, macOS, Linux and Haiku, in most of the browsers that run on all those operating systems.


You can definitely run Qt on various platforms. That's the whole point of Qt to begin with :)

The ability to have CSS in most browsers (a total of three of them as of 2019 since IE is switching to Chromium) is not really an excuse for the state of CSS.


> QT based projects on Windows, macOS, Linux and Haiku,

Qt supports all of those and much more.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: