11 ms·
Incomplete List of Mistakes in the Design of CSS
- terandle 8y agoSome of these seem very nit picky but if we are doing that my pet peeve was that the “color” property should have been named “text-color”
- aphextron 8y agoOr just "font-color" to match font-face and font-family. etc. That still gets me almost every time.
- maxxxxx 8y agoColor is not a property of font so I'd stick with "text-color"
- koboll 8y agocolor is as much a property of font as size is
- paulddraper 8y agoTraditionally, font is just the shape of the characters (size, weight, italics). Other things (alignment, underline, wrap, color). This is because "fonts" were originally physical typesetting blocks. Some designers go further and say font refers only to the files and file formats; other things are the "typeface".
- einr 8y agoI believe the traditional usage is something like this: Helvetica is a typeface, Helvetica Bold Italic is a font.
- taejo 8y agoAlmost: Helvetica is a typeface family, Helvetica Bold Italic is a typeface, Helvetica Bold Italic 10pt is a font (or rather, the font is a case full of bits of metal with Helvetica Bold Italic 10pt)
- dcbadacd 8y agoYeah, but fonts being recolored is a different thing than fonts having a color. https://www.colorfonts.wtf/ https://www.colorfonts.wtf/
- thrower123 8y agoIn practice it usually is part of the same font selection dialog in most software that you use to select the font face, size, bold/italic/underline, etc. For example, the relevant button in Word is titled "Font Color"
- ZenPsycho 8y agoHold on a second here! It actually becomes the "currentColor" color in inlined SVGs, and the default fill color in svg when no color is defined. so oops, not a property strictly of text or fonts anymore. Maybe "foreground-color" would be appropriate?
- SimeVidas 8y agoIt affects non-text as well, e.g., https://jsbin.com/wodevam/edit?css,output https://jsbin.com/wodevam/edit?css,output.
- ronaldj 8y agoWow. I've been writing CSS for 10+ years. I never knew that.
- GlennS 8y agoSurely "text-colour"?
- mcphage 8y ago(1) it should have been designed around what people actually try to do: three column layouts with headers and footers, aligning content in the middle, pinstriping (this one isn’t as popular anymore), drop shadows, etc. Instead, all of these things required either hacky workarounds, or stepping outside of CSS entirely. The first decade of CSS was “look at all these things you can do that you don’t want to, and you can use them so long as you don’t try to make the kind of sites your clients actually ask for!" So fucking stupid, it still makes me angry years later.
- JJMcJ 8y ago> three column layouts with headers and footers I was appalled when I saw what was needed to make this use case, used by 1/2 he web pages in existence.
- ZenPsycho 8y agooriginally CSS had no layout facilities. (as it should be, see other comment). Layout was hacked in to css by abusing the "float" property into doing things it was never meant to be doing.
- mcphage 8y ago> Layout was hacked in to css by abusing the "float" property into doing things it was never meant to be doing. So if CSS wasn’t supposed to do layout, despite that being what people needed, and if you weren’t supposed to use tables for layouts despite that being what worked... then what on earth were you supposed to be using for layout? I don’t recall any other serious options out there.
- irrational 8y agoIn the beginning... the web was never envisioned to be what it is today. The notion that anybody would want to do layout like publishing software didn't cross anyone's mind. Originally the web didn't even have images! It was just text and links. It was just a way to pass text documents around easily. Of course, then the designers came along and said "I want it to look like this" and webmasters (as we were called back then) had to figure out some way to do it. The only realistic way to more or less do it was to use tables (which, of course, was not their intent, but when all you have is a hammer...)
- ZenPsycho 8y agohere's my pet peeves: 1. CSS should not have adopted a hyphenated naming scheme for properties, since it makes it difficult to access css properties from javascript or other languages. 2. CSS should never have been used for layout, and nobody should have suggested it should be. CSS defines properties on individual elements, while layout fundamentally needs to define relationships between elements, which requires really icky hacks and implied relationships in a language like CSS, e.g. the definition of percentage units (percentage of what?) being mostly arbitrary and context sensitive, So you are forced to learn what all those context rules are to get the desired outcome. What does height: 80% mean? 80% of the parent element's width? 80% of the parent element's height? 80% of the window width? who knows? 3. The naming of properties and values is entirely inconsistent. Sometimes "none" works. sometimes it doesn't. What even is going on with "white-space"? 4. Who allowed Microsoft to add "pointer-events" properties to css? This is a tragedy. 5. em based font sizing seems like a really good idea until you use it in some system that will arbitrarily nest component elements until the innermost reply to a comments thread is either microscopic or 3 characters per line.
- leeoniya 8y agopointer-events: none; is actually pretty useful in many cases when you temporarily need to disable interactions, like drag/drop
- ZenPsycho 8y agoIt's useful as long as every browser supports it. When it doesn't, and you want to polyfill, the polyfill needs to download all linked CSS files a second time, implement a CSS parser to find the pointer-events properties, and after all that, patch in not entirely identical behaviour with javascript. But then, this is behavior. what's it doing in a language that's supposed to be strictly about style/presentation? Why isn't it an html attribute instead?
- fouc 8y agoWould be nice to have that polyfill at the webpack build level instead of the browser. Generate css files specifically for older browsers.
- SimeVidas 8y agoEmphasis on incomplete.
- Carpetsmoker 8y ago> Box-sizing should be border-box by default. It was for many years for >98% of the users when IE had near-total market dominance. But W3C rejected sanity and refused to fix the spec, insisting that IE should break every website on the planet and implement the W3C box model. This was a major PITA for anyone who cared enough to design a website that worked equally well in IE, Firefox, and Opera, which became an increasingly annoying problem as Chrome and Firefox gained in popularity. A great many developer hours (including mine) have been lost on the W3C's foolish stubbornness.
- gsnedders 8y ago> It was for many years for >98% of the users when IE had near-total market dominance. It never reached that high: IE was only around 80% at the time of IE6's release (and IE6 was the first version of IE/Win to support quirks mode, allowing the change without breaking sites; IE5/Mac had shipped a year earlier, but never had the marketshare its Windows counterpart had).
- devwastaken 8y agoI don't think things like syntax and schemes are the real bad parts. The real bad part is that CSS is in no way designed to be interacted with by anything but CSS. Just yesterday I was making a music player position bar, and using CSS transitions to have it smoothely update itself. Set the duration of the transition and it goes on. But what about when the transition takes effect? JS doesn't know when a style is actually updated and can then have a new property overwriting it to make the transition happen. If you do properties too quickly the transition won't happen. Such as if a user clicks on the bar to change the position, I have to hack in a 100ms setTimeout to set the new transition duration after stopping the transition with transition:none; Why can't I control a transitions location? Chrome's animation viewer can go back and forth in time easily. Why isn't interactivity seperate from CSS? CSS elements cannot effect those outside of its scope. You require JS for just dumb simple things that should be natively supportable. For instance you can make CSS do things based upon URL hash names like #somename, but you can't set them in CSS. You can't change attributes on elements, or classes or anything like that. I think we've gotten to the point where JS is the 'programming language' of a webpage that has intentions far beyond rendering and interactivity. Perhaps we need a newer kind of CSS that's made for dynamic interactions. That way great UI's can be built in a safer css-like environment.
- _hardwaregeek 8y agoYep yep. CSS in JS removes some of the pain points but still, fundamentally, CSS cannot communicate with JS in a universal, elegant way. Honestly, CSS in general is awful. How did we only just get decent centering with flexbox? How is flexbox still inconsistent across browsers? (Try setting a child of a flexbox container to 100% height.) The days of needing separate constructs because of bandwidth are over. We need something to unify CSS and HTML and JS into a UI builder that doesn't make you want to tear your hair out when you have to center a div over another div and give it an animation.
- VonGuard 8y agoThe thing i hate about CSS is how unstructured it can be. You just sorta list whatever you want and it's suddenly a style sheet. No headers, no footers, no must includes.... DO I use quotes around this value? Do I not? Does white space matter? It's the most intimidating language I've ever used just because it feels so open and uncontrolled and nonsensical... I always thought CSS was some leftover abomination from the days of Netscape.
- jiveturkey 8y agoare there any efforts underway to rectify the horror of css?
- MaxBarraclough 8y agoWhen it comes to widely-used web standards, we tend to be pretty much stuck with them forever. They get extended, but not replaced.
- fouc 8y agoIt would be nice if it was possible for devs to create their own CSS-like DSL and get the browser to use that instead of CSS.
- pmarcelll 8y agoI started to work with HTML and CSS recently, so I'm still learning. To me it seems that CSS preprocessors are the closest thing to what you descibed, although the output is still CSS.
- tokyodude 8y ago> background-position and border-spacing (all 2-axis properties) should take vertical first, to match with the 4-direction properties like margin. Is there some reason why margin/padding is top, right, bottom, left instead of left, top, right, bottom or left, right, top, bottom or both of which would seem more common in other APIs
- Haydos585x2 8y agoMy guess is that it works the same way a clock does. Purely a guess though.
- adamrezich 8y agojust to give you more TRouBLe
- Zarath 8y agoWow I just started making websites of my own recently and have encountered so many things that are immensely infuriating about how the language is interpreted that I've been thinking about starting a list myself. They seem to favor implied behavior rather than explicitly defined behavior which is incredibly annoying. For example, space between inline-block elements that is not accounted for by margins. The fact that margin-top and margin-bottom percentages are computed based on the width of the parent element, not the height. The fact that certain properties like max-height are oftentimes not respected if they use a %, even if the height can be precisely calculated. The fact that I have to add body { margin: 0; } to everything. I'm sure there have been more but just what I can think of off the top of my head. Oh, and COLLAPSING MARGINS.... WHAT THE HELL
- usaphp 8y agoThey seem to be confusing when you are just starting designing, but once you spend more time with it - most of it starts to make sense > The fact that margin-top and margin-bottom percentages are computed based on the width of the parent element, not the height. It's actually much better this way, imaging a block of text with varied content. If you had margins calculated based on a height - you will have a margin that depends on text content size, which is wrong, instead you want your margins to depend on a screen size width, not the content inside > Collapsing margins It's a great solution as well, imagine you have a div that you want to have margins on top and bottom of 20px. It makes perfect sense to collapse margins if you have say 2 of those div's running one after another, because you don't want them to have 40px margin, you only want 20px. So when there is another element that is not that div - you will still have your desired 20px margin.
- Zarath 8y ago> It's actually much better this way, imaging a block of text with varied content. If you had margins calculated based on a height - you will have a margin that depends on text content size, which is wrong, instead you want your margins to depend on a screen size width, not the content inside So using width to compute a vertical margin is somehow a better solution? If I wanted a margin of a fixed size that doesn't dynamically change based on content, I would define it exactly using vh, or px. > It's a great solution as well, imagine you have a div that you want to have margins on top and bottom of 20px. It makes perfect sense to collapse margins if you have say 2 of those div's running one after another, because you don't want them to have 40px margin, you only want 20px. So when there is another element that is not that div - you will still have your desired 20px margin. I just want the code to behave as I instructed it. If I say this div should have 20px of margin on top and bottom, then it should. Don't go behind my back and say "we know better" and delete it. There seem to be plenty of ways to achieve only 20px on successive divs without resorting to what is basically undocumented behavior that explicitly contradicts what is programmed in the file. For example, I could just give all divs 20px of margin-top, and then style :last-child with 20px margin-bottom. This is almost certainly a better solution than resorting to collapsing, at least in my opinion.
- Brajeshwar 8y ago“New ideas will come along, but they will extend CSS rather than replace it. I believe that the CSS code we write today will be readable by computers 500 years from now.” — Håkon Wium Lie, co-creator of CSS.
- c-smile 8y agoYeah and that puts enormous pressure on what we put there. That flexbox, half-baked and overcooked at the same time. And display:grid at the same time but using completely different concept of flexibility (fr units in grid) and some strange property in flexbox. What, the hell, this means: div { width:400px; flex:2; } ? Just a humiliation of CSS box model.
- deleted 8y ago[deleted]
- c-smile 8y agoFr units (fraction, measure of flexibility) shall be allowed on width,height,margin,padding and borders. Instead of using flexbox I should just be able to write: label { width:1fr; } input { width:2fr; } to distribute the widths in 1:2 ratio. Easy, obvious and has very good mental model - flexes are just springs where fr unit expresses their strength.
- bsheir74 8y agoCss is fine. Not perfect but fine. It's an approachable way to style documents that look ok on different devices. It's best when used sparingly. When I see people complain about css, they usually fall into a few camps. First theres the person who wants everything to look the same everywhere. They want web design to work like a print document. Sorry but thats now how it works. And then theres people who are writing web apps, not documents. I feel sorry for those folks. Cuz css does suck for that, and there's no easy solution. But for documents, css is fine. Although it wouldnt be as important if you all marked up your documents correctly in the first place.
- pjmlp 8y agoThe problem is that there are plenty of us, because although it is possible to make a living with native projects, it is Web that pays most of the bills on UI development. At least 2018 is the year we finally catch up with the native 90's regarding components.
- c-smile 8y agoflexbox, grid, table,etc. shall be values of some 'flow' or 'layout' property as they define layout model of element's content. 'display' values shall just define requirement of the element to its container: display:inline, display:inline-block require flow:text container and display:block require flow:vertical, flow:horizontal wrapper. So it shall not be display:inline-table, display:inline-flexbox and the like.
- c-smile 8y agoIt MUST be a way to reproduce <center> HTML by CSS means solely. No way so far.
- rimliu 8y agoI know at least three without using tricks like negative margins.
- deleted 8y ago[deleted]
- irrational 8y agoWhat wrong with display:flex, justify-content: center, align-items: center;?
- combatentropy 8y agoMost of these are nitpicks. Some are preferences that I would oppose. CSS is inspired by the style sheets of yore, of typeset publications made by ink-smeared metal pressed into paper. A magazine or newspaper might have a "style sheet" that said things like, "Paragraphs shall be 10-point Caslon" and "all second-level headings shall be hanging headings, outdented 5 picas." Before web browsers got a hold of them, stylesheets had already entered the electronic world in desktop-publishing software like QuarkXPress and even Microsoft Word. The problem they were trying to solve was, how do you update the look and feel your website easily? This was in the days when most websites were static HTML files, and updating all your articles meant changing a file for every page. The most famous and beautiful example of the power of Cascading Style Sheets is CSS Zen Garden. In 2003 Dave Shea provided an unstyled page of HTML, and then designers from around the world contributed stylesheets that transformed the page into wildly different designs (http://www.csszengarden.com/ http://www.csszengarden.com/).
- praptak 8y ago> CSS is inspired by the style sheets of yore Which is in my opinion the reason why it sucks for most of its current use cases. Layout of a paper document and layout of a web page are very different. The web "page" often isn't even a page but rather a GUI for a computer program.
- combatentropy 8y agoFrom the beginning, CSS tutorials said just what you said, that the web is not the printed page and that you should not strive for pixel-perfect layout.
- vertline3 8y agoA new software engineering maxim: "The bar of complaint will rise to meet any improvements"
- afarrell 8y agoNah, I've definitely used some software which had fantastic cognitive affordances, fit in my working memory really easily, and which people broadly agreed were fantastic. http://docs.python-requests.org/en/master/#the-user-guide http://docs.python-requests.org/en/master/#the-user-guide
- stevebmark 8y agoI think you forgot the "C" in CSS I think you forgot that everything is in a global, conflicting namespace, where people thought global naming conventions like BEM were a good idea vs actually solving the problem
- tannhaeuser 8y agoThe principal mistake of CSS IMHO is that it invented new syntax for what should've gone into HTML attributes (like SGML LINK and FOSI did). This then led to inconsistent ways of manipulating display properties (CSSOM etc.) and also to the identity crisis of HTML (postulating "semantic" HtML when markup is as syntactic as it gets).
- jetzzz 8y agoCSS should have used linear color space for gradients and blending instead of sRGB. I don't want CRT emulation in 2018. https://lists.w3.org/Archives/Public/www-style/2012Jan/0615.html https://lists.w3.org/Archives/Public/www-style/2012Jan/0615....
- sireat 8y agoI get a serious case of impostors syndrome when it comes to CSS. 20+ years of HTML, 15+ of writing Javascript, loving ES6 but CSS gives me fits. What I hate the most that there really is no clear parent - child abstraction. This parent child abstraction (all the way down to turtles) is present in most reasonable UI frameworks. I'll take Windows Forms or Qt any day of the week over CSS. In CSS this abstraction leaks all over the place. Elements can do whatever the hell they want (z-index, pos, box sizing before International Border-box Day, etc). CSS Grid was supposed to solve layout. It still has a long way to go. For example, teaching at a bootcamp I ran into the following: https://learn.freecodecamp.org/responsive-web-design/css-grid/limit-item-size-using-the-minmax-function/ https://learn.freecodecamp.org/responsive-web-design/css-gri... By setting a hard limit in pixels(as required in the exercise) you break the grid for smaller sizes because items go outside parent. So what do I tell my students? Avoid px whenever possible, use media queries, em/rem and percentages. That's all good, but there is no coherent mental model to think about UI besides bunch of arbitrary boxes which can do ANYTHING. In a good UI your child elements should stay within the parent(via scroll etc), not so with CSS. There are no guarantees whatsoever. Someone will come up with !important !important pretty soon.
- c-smile 8y agoIt shall not be `display:none` but rather `visibility:none;` to exclude element either from layout or rendering trees.
- sureaboutthis 8y agoA lot of the complaining in this thread is not what the article is about but I always find that too many people look at CSS usage from too high a vantage point without understanding the fundamental workings. It is that issue where people find themselves in trouble getting properties to interact with each other as expected. One example, and not the best one, is 'width'. People want 'width' to be the total width of an element as displayed in the viewport but 'width' was never specified that way. It is the width of the content, such as text, exclusive of padding, borders and margin. But people don't read the specification, then struggle getting layout to look as they wish and blame CSS as not working "as it should". Quite frankly, in most cases, CSS works exactly as it is specified and most of one's problems go away once that is understood.
- bunderbunder 8y agoThere are legitimate grounds to argue that the way CSS was specified is wrong. The fact that people find it so confusing is one. If people intuitively think that "width" is the total width of an element (an entirely reasonable assumption, mind), then that would imply that CSS chose an unnecessarily confusing name. Another is from the mental load perspective. If I'm doing a layout, I want to figure out how things fit by looking at the total space they take up. _That_ is the width I care about. Leaving margin out of it makes sense, but having to mentally add the padding and border to get from "width" to "no really width" is annoying.
- Raphmedia 8y ago> The fact that people find it so confusing is one. Problem is that they never learned it. They jump in thinking "I know how to code, everything should make sense to me" and hit a wall. CSS is not like regular coding. I went to a technical college and one of the class was on CSS. It's the class that everyone aced. Even the people who would fail miserably in every other parts of the industry. CSS is not hard but it requires some memorization.
- nine_k 8y agoLogic in many cases is preferable to memorization. Not only you need to memorize less upfront, you can expect new additions to follow it, and not need to memorize much to start using them. Compare how easy it is to pick up e.g. Spanish writing vs English writing vs Chinese writing, assuming that you already can speak it.
- kryptiskt 8y agoFor what could have been: "The Languages Which Almost Became CSS" https://eager.io/blog/the-languages-which-almost-were-css/ https://eager.io/blog/the-languages-which-almost-were-css/
- quarterlyresult 8y agoIt wasn't until recently that I finally realized how user-friendly CSS was designed to be. As I started to fiddle with LaTeX in search of better looks on my papers, it gets more and more clear that the design of CSS is thoughtful and ergonomic. It is so painful to work with LaTeX that I could not believe I had complained about CSS. What would take a few lines of clear code in CSS would take dozens of undecipherable sequence of commands in LaTeX. For instance, just changing the font size of section headings in LaTeX is not a trivial matter. Eventually I ended up with this: \renewcommand\section{\@startsection {section}{1}{\z@}% {-3.5ex \@plus -1ex \@minus -.2ex}% {2.3ex \@plus.2ex}% {\normalfont\normalsize\bfseries}} It would take just h1{font-size:1em;} in CSS. The problem of TeX is that it has no abstraction that is easy to work with. In CSS, you have elements -- actually, a tree of them -- and they have their own attributes, and in addition, they can be easily modified. You can even give elements a class to have them have common properties. All things that do not exist in TeX. I did not know how the concept of a heretical structure of elements and their attributes give you an intuitive interface to a layout. Certainly, CSS might not provide you with full control over how things are rendered. There is little doubt that TeX excels in that regard. But how many people need to be able to easily create a new math operator? Is it worth making it difficult to change the font size of headings?
- sizzle 8y agoIf someone just getting started in front end dev as a hobby and knows HTML, CSS classes, IDs, selectors, basic inheritance rules and the most of the top commonly used CSS declarations but nothing about centering or aligning elements, other than abusing the box model to move elements around the screen: e.g. .class { margin-bottom: -50px !important; } would you recommend starting with CSS Grid or Flex box tutorials for learning alignment and why? I'm getting the hang of {flex: # # #%;} grow, shrink, basis construct, but is CSS grid the future and should I cut my losses and start there? My time is limited as this is not my main profession. Thanks in advance.