4 ms·
I think CSS has become the thing it was supposed to prevent. A modern web page is impossible to render as anything other than a web page; you can't separate the
by lmm 12y ago
I think CSS has become the thing it was supposed to prevent. A modern web page is impossible to render as anything other than a web page; you can't separate the styling from the content, and if anything the complexity of CSS makes doing so harder than in the days of font tags and tables. Users were supposed to be able to override the styles of their pages, but have you ever tried to do that lately? (e.g. I wish I could make all the fixed-width pages on the web full-width).
When CSS is being generated by programs, you might as well have those programs generate inline styles - what would we lose? And we would gain in simplicity.
- jgalt212 12y agoInline style would definitely be a bandwidth hog, that's for sure. As to how much extra bandwidth it would take up and would that make a noticeable difference given that most bandwidth is used for images and video is up for debate.
- lmm 12y agoI think we'd regain any bandwidth cost through compression. Compare the rise of VNC (and VNC-like protocols) compared to X - it turns out there's no advantage to sending drawing commands rather than sending bitmaps, because they both compress to the same thing.
- al2o3cr 12y agoAutomatic inlining is used in some contexts, notably emails where everything else works barely-if-at-all. The biggest loss of using inline styles everywhere would be for instances where the appearance of the DOM is changing dynamically. Instead of just saying "hey, make that node have the class 'shinyWidget'", you'd wind up needing to specify all the styles that shinyWidget includes - and then reliably un-apply them when the node was no longer shiny. Bonus fun if two things want to change the style of a single element, though that's still sometimes a headache with CSS and specificity rules.
- e12e 12y agoI always felt CSS solved the wrong problem. It's too low level -- and it doesn't really help separate content from elements as much as it should. It feels like the designers looked at what people were already doing with tables (forcing old, DTP-style layout on web pages, ignoring the ability of user-agents to prefer how content should be presented) -- and tried to separate that layout out from the mark-up. So you ended up with two types of mark-up, just as with tables, semantic mark-up (h1, p, em, img, a/href, li) and "layout mark-up" (span, div). To a certain extent CSS was successful in making table-markup semantic again. But pages are still evolving away from being easy to parse for content, just as they were with table-based mark-up. I still think Adobe's proposal: http://www.w3.org/TR/css3-regions/ http://www.w3.org/TR/css3-regions/ is a much better way to solve the problem how "how can we let publisher dictate how the pages should look, users be damned, but still keep the html-markup simple and semantic" -- than the traditional CSS model. All that said, sites like the legendary CSS Zen garden, does illustrate that CSS is a powerful tool, and offers quite a few improvements over plain old html+tables: http://www.csszengarden.com/ http://www.csszengarden.com/ Still wish they'd gone with something that was more informed by Desktop Publishing Software (along with some proper support for breaking up words, a la: https://code.google.com/p/hyphenator/ https://code.google.com/p/hyphenator/ ).
- lmm 12y agoThe CSS Zen garden made sense in an age where people hand-wrote their pages. But today any CMS could achieve exactly the same results with plain html + tables - the pages are already rendered on the server (or in Javascript) based on a template + content (probably in markdown or some such).
- e12e 12y agoI disagree. It is much more feasible to have templates and widgets that work across different CMSs and blog platforms, if you can have a common html target to style with css (and enhance with js). And even if you don't think ready-made templates are a good idea (eg: using a layout made for wordpress with ghost, or vice-versa) -- many companies have heterogeneous solutions where the "web site" is actually made up of various independent systems, unified behind a proxy like Traffic Server or Apache with mod-rewrite. Having a sane html template to target, makes it much easier to have a uniform looking (and behaving) site -- and you only have to fix css bugs in one place.
- userbinator 12y agoUsers were supposed to be able to override the styles of their pages, but have you ever tried to do that lately? That probably has more to do with the "appification" of web sites than anything else, where huge amounts of JS and CSS are used together to produce a poor imitation of a desktop application. Pages that aren't SPAs are far more amenable to styling changes, and are often quite readable (or even more readable) even with all author-CSS disabled. When CSS is being generated by programs, you might as well have those programs generate inline styles - what would we lose? And we would gain in simplicity. I see inline styles as being more of a "one-off" thing, while CSS selectors can affect many nodes in the tree, so I think both have their uses. The "simplicity" is offset by the increased memory consumption and overhead of parsing every inline style, when much of them will be the same. You could argue that pages could be compressed and maybe browsers could use methods to identify duplicate styles so they can also compress them in-memory, but why do all that (i.e. making every client, on every page reload, have to expend the resources to derive this information) when you can group together common styles under one selector for which the browser will naturally treat as one object?
- lmm 12y agoMaybe inline is an extreme example - but suppose we didn't allow the selector syntax, only a simplified form of CSS where the only selector is a single class, and only allowed one class per element? Then the browser could share everything it can share today - it still needs to compute the final style for every element on the page, so the only way it can reuse styling information is if two elements come out with exactly the same style - but it would be much easier to see why any given element was styled the way it was, the browser implementation could be simpler, and our programmatic frameworks for styling components on the page would still be able to help us avoid repeating ourselves.
- easytiger 12y agoThe top article on hacker news created a fuss because it's idiotic interactive book type layout made it horrible so people had to disable it
- adregan 12y agoWith regards to separating style and content (and layout): It seems to me that HTML is no longer the purest form of content. I've been thinking that having your content in an API (or markdown or text files in the case of static site generators), using HTML for the layout (inline styles maybe, or JS driven positioning), and CSS for the styling of the content creates a more flexible and future friendly flow. Then stylesheets could be far simpler. Layout needs to move to a new layer of the stack perhaps.
- T-hawk 12y agoThe thing is, layout is content. Even right here on HN. One comment being a reply to another is indicated visually with a level of indentation. That's semantic meaning. A comment saying "I disagree" carries vastly different meaning depending on what comment is its parent. If you remove layout from HN, you remove threading from conversations and lose or change the meaning of posts. We use layout to indicate meaning in all sorts of ways. Even a simple set of tabular data with two columns will depend on visual layout. An item for sale needs to be next to the correct price for that item, for example. An image with a caption depends on having the caption spatially near the image. I agree that it feels like layout belongs in a new layer of the stack. But how do you do that? You'd need all sorts of semantic meaning to be expressible in the data structures from the API. Things like parent/child post hierarchy, or item/price, or image/caption, or any number of other relations. How do you generalize that? This sounds tantamount to and as intractable as strong AI in the area of knowledge processing.
- sp332 12y agoYou could have a semantic relationship between two comments, and then have lots of options for how you want to style it. They're separate. You could draw lines between them, or indent them by various amounts, or draw a box around them, etc. Styling is how you express the semantic meaning in a particular context, but changing the styling shouldn't change the semantics.
- wefarrell 12y agoSounds a lot like the web of the mid 2000's with XML and XSLT files.