News for hackers. Stuff that matters.
Re:CSS Absolute Centering by gamegoblin on Saturday August 10, 2013 @11:46AM (#6191452)
I have just started doing web programming in the last month after several years of applications programming.

It feels like to me, and someone please tell me why I'm wrong, that the amount of hackery that goes into making webpages look the way web designers want them to is astounding. I google for solutions to various problems and the top rated comment on StackOverflow says "...there isn't a good way to do this in CSS, but here is this hack...".

I feel like somewhere in the universal programming ether there exists a beautiful unification of HTML, CSS, and JS that doesn't rely on any ugly hackery, and it's just waiting to be found and start a brave new world of web programming...

Re:CSS Absolute Centering by crazygringo on Saturday August 10, 2013 @12:35PM (#6191651)
As someone who's done an insane amount of front-end programming, you're entirely right.

Sometimes I wish I could get back all the brain cells that I've wasted on the hundreds of "little tricks" you need to know to get things working -- and then working cross-browser.

Short answer: CSS is just a horribly, horribly, terribly badly designed language. It's the absolute worst. Don't let anybody tell you otherwise. It's that, it's what we've got, and it is awfully powerful in many ways. But it's complete rubbish in others, which include a lot of incredibly basic layout things.

Re:CSS Absolute Centering by gcv on Saturday August 10, 2013 @01:39PM (#6191929)
crazygringo is absolutely right.

When the committee responsible for CSS started working in the late 1990s, it seems to have lacked any members who knew anything about layout. Certainly, the browser was a new challenge, but automatic layout engines had existed for decades by that point. TeX, for example. While it is a beast, I have usually found it far easier to get its glue-and-boxes model to do what I want than wrestle with CSS.

To make matters worse, the CSS people considered it a badge of pride that CSS lacks programming features. Allow variables to represent colors so we don't have type #f0c450 all over the place? Nesting constructs? Perish the thought!! That would make it look like a programming language, with scopes! As a result, we now have LESS and Sass which plug up the worst holes, but do nothing about the fundamentally brain-damaged layout model.

Re:CSS Absolute Centering by steveax on Saturday August 10, 2013 @02:56PM (#6192221)
You're comparing a layout engine for print where the creator has control over all aspects of the presentation (font size, page size, etc.) with CSS where the content is displayed in an environment where the user is in control of many of those? Apples to Oranges. Pretty much all the things that are difficult to do in CSS have to do with this uncertainty and lack of control.

For example, centering in CSS is trivial if you're only doing it for one viewport size, font, font size.

Re:CSS Absolute Centering by lobster_johnson on Sunday August 11, 2013 @01:43AM (#6194006)
It's true that it is harder to design a model based on different viewports and so on. However, this does not excuse the ridiculous shortcomings of CSS, especially in this case.

CSS doesn't really have vertical positioning within arbitrary boxes, which is insane if you think about it. This shortcoming has nothing to do with viewports or fonts or whether it's screen or paper. After all, the rule "box B is to be vertically centered within box A" is not dependent on a particular medium such as print or screen. The rule "box A is to be 100 pixels tall" adds medium-specificity, but that's different.

Rather than providing rich high-level rules to create simple, responsive layouts, CSS makes one jump through hoops to accomplish trivial things like vertical positioning, and gets mired in finicky micro-details and a cumbersome, inflexible layout model. It breaks down quickly; for example, only recently, with the introduction of "box-sizing: border-box", has it been possible apply percentages to box sizes that have padding. (Before, if you had two boxes with "width: 50%", they would wrap if you applied padding.)

As an aside, I am personally not convinced that the CSS promise of separating presentation from content has paid off. In any serious web app, the DOM is visual, and separating CSS from the DOM makes no sense. It's useful as a way to organize code and to share style rules, to be sure, but those benefits don't come from content/presentation separation. I wish we had an inverted model — a visually oriented language concerned only with presentation (think SVG, only not limited to vector graphics), with a separate data language concerned exclusively with data.

Re:CSS Absolute Centering by gcv on Saturday August 10, 2013 @04:34PM (#6192577)
As I said, the browser is a new challenge, and I was referring exactly to the problem of presentation flexibility. However, I'm pretty sure that the boxes-and-glue model can handle flexible viewport and font sizes as inputs from the browser, rather than specified by the user in terms of page size.

CSS has boxes, more or less. It does not have glue in any meaningful way, i.e., it does not give a direct way to specify what happens in between the boxes. Pretty much all the things that are difficult to do in CSS have to do with the difficulty of describing what happens in the negative space.

Re:CSS Absolute Centering by ianstormtaylor on Saturday August 10, 2013 @01:53PM (#6191978)
You should distinguish between whether the syntax and general principles of the language are horribly designed or whether the current language features are lacking. They're very different critiques. The former results in people saying we need to completely scrap CSS and find a new way to layout pages. The latter results in people putting more pressure on and getting more involved in the CSS working groups and browser implementations to get new features pushed to consumers.
Re:CSS Absolute Centering by crazygringo on Saturday August 10, 2013 @02:03PM (#6192014)
Well, there's nothing inherently wrong with the syntax or structure of CSS (and things like LESS make it even nicer).

I'm talking about things like the way "floats" transformed from a way of wrapping text around pictures (good) to a general-purpose layout mechanism (disaster).

About how there's no way to put a footer at the bottom of your page that stays at the bottom if your content is short, but gets pushed down if your content is long (the normal desired use case).

About how the only way to get two columns of equal height, but that expand to fit the text, is to use a <table>, but that this is supposedly disallowed because it's "unsemantic".

About the complete disaster that float-clearing is, yet how it's central to almost all modern CSS layouts, and fixed only by bizarre byzantine hacks like "clearfix", overflow:hidden (which breaks other things), or the classic "<div style="clear:both;"></div>" which needs to be peppered throughout HTML, negating the whole supposed distinction between HTML and CSS.

And finally, the fact that the width of an element doesn't include its border and padding, making for nesting div's that include border and padding much more difficult than it should be. (Although this is, of course, fixed in newer versions of CSS.)

In the end, it's not really "current language features", but mainly the disastrous decision to adopt floats as a basic layout concept, instead of grids/columns/etc. (Which is, of course, why so many people wind up using <table> in the end, which has its own problems...)

Re:CSS Absolute Centering by ianstormtaylor on Saturday August 10, 2013 @04:51PM (#6192633)
No one ever really decided that floats were the way to layout columns as far as I know. It's completely about "current language features". The standards group was just too slow to implement a decent alternative so we had to use floats. But flexbox[1] is the solution to lots of the problems you are mentioning, and it's almost support in all modern browsers, so very soon we can start abandoning floats and absolute positioning in our layouts.

Meanwhile, CSS is still a well-designed language in terms of syntax and principles. We just need a few more features that weren't in the original spec as new uses for the web emerge.

[1]: https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Flexi...

Re:CSS Absolute Centering by chestnut-tree on Saturday August 10, 2013 @03:33PM (#6192348)
I actually wish that CSS didn't have so many different ways to write a rule. Have just one way to write a rule and enforce it strictly.

In other words, instead of being able to write any of these

  padding: 0 0 0 0;
OR

  padding-top: 0;
OR

  padding: 0;
Just settle on one (the first one in my opinion for this rule) and get rid of all the other alternatives.
Re:CSS Absolute Centering by dragonwriter on Saturday August 10, 2013 @03:39PM (#6192371)
The first one (and the third one, which is closely related) doesn't provide any mechanism to override a single of the padding settings while inheriting the rest.

If you could only have one mechanism, and you weren't going to lose significant functionality, it would have to be the longhand padding-top, padding-bottom, etc., set.

But I think having the shorthand rule is worthwhile.

Re:CSS Absolute Centering by chestnut-tree on Saturday August 10, 2013 @04:02PM (#6192443)
I didn't think padding was inherited?

The reason I chose the first example over the second is that, if you only ever specify padding-bottom for example, what are the default values for the other unspecified padding properties? This is why we have the CSS reset technique and normalize.css (more hackery).

I would make it mandatory that you declare all four values for the padding rule to remove any ambiguity. That would also mean eliminating shortcuts like

  padding: 5px 10px 15px;

  padding: 5px 10px;
I think having shorthand rules just adds to the ambiguity and complexity of CSS, because, as you rightly point out, each of the variations has a subtly different meaning from each other. This is not a good thing (in my opinion :-) especially when you consider how lengthy and complicated stylesheets are nowadays for many websites.
Re:CSS Absolute Centering by ianstormtaylor on Saturday August 10, 2013 @04:48PM (#6192627)
It's not about inheritance, it's about specificity. If you have a generic module that specifies

  padding: 5px;
And you actually the bottom of your element to have more padding, you need to be able to do adjust the bottom padding independently

  padding-bottom: 10px;
Otherwise, you'd be required to tightly couple your our padding requirements with the defaults of the original module

  padding: 5px 5px 10px 5px;
Re:CSS Absolute Centering by lmm on Saturday August 10, 2013 @05:28PM (#6192738)
CSS requires you to do that in plenty of other places (e.g. if you make your border 1px wider you have to make the element it's on 2px narrower.)
Re:CSS Absolute Centering by callmevlad on Saturday August 10, 2013 @06:16PM (#6192879)
If you set box-sizing: border-box [1], you don't need to worry about the latter.
Re:CSS Absolute Centering by emn13 on Sunday August 11, 2013 @04:38AM (#6194351)
Even without border box you can achieve that quite easily (since the conceptual border-box 100% is the default for blocks); you simply need more wrapper elements.
Re:CSS Absolute Centering by lmm on Sunday August 11, 2013 @04:12AM (#6194291)
If only that worked on all the browsers I was required to support...
Re:CSS Absolute Centering by fractaled on Saturday August 10, 2013 @04:40PM (#6192602)
How about if you want to override just one part?

It doesn't make much sense with "padding", but for something like "border: red solid 2px;", how do you override just the color if you don't have the individual components broken out?

Re:CSS Absolute Centering by chestnut-tree on Saturday August 10, 2013 @05:50PM (#6192810)
Good point. I should have qualified what I wrote previously by saying some CSS properties (like padding) could be simplified with just one way of writing the syntax. I say simplified (but not necessarily shortened) because it means you no longer need to explain that property x can be written this way. Or it can be written that way. Or it can also be written yet another way.
Re:CSS Absolute Centering by dragonwriter on Saturday August 10, 2013 @04:21PM (#6192527)
> I didn't think padding was inherited?

I forgot that padding required explicit "inherit".

So, bottom line, yes, it would seem to make sense to just have the single-line complete version:

  padding: *w* *x* *y* *z*
Re:CSS Absolute Centering by PavlovsCat on Saturday August 10, 2013 @04:48PM (#6192626)
That doesn't matter, you had it right the first time and there is a still a reason and a need for being able to specify single elements of a property. Say, you set a specific font size and font family for the body, but want some element to have a slightly smaller font size... having to explicitly repeat all the stuff would make CSS unworkable. (look up the "font" short hand, there is quite a lot in there, and that's just one of so many, e.g. backgrounds and background images)
Re:CSS Absolute Centering by dragonwriter on Sunday August 11, 2013 @11:24AM (#6195153)
I'm referring specifically to padding; whether reduction of options is appropriate in other cases I didn't address. The balance if brevity, specificity, and distinct function (e.g., inheritance) is not the same for each of the cases where CSS has multiple forms with overlapping function.
Re:CSS Absolute Centering by joshuacc on Saturday August 10, 2013 @03:27PM (#6192326)
"About how the only way to get two columns of equal height, but that expand to fit the text, is to use a <table>, but that this is supposedly disallowed because it's "unsemantic"."

This is incorrect. Using display: table and display: table-cell allows you to achieve equal height columns.

Re:CSS Absolute Centering by barrkel on Saturday August 10, 2013 @06:51PM (#6192970)
Well yes, if you make a div work like a table and a nested div work like a table cell, you can indeed technically get away without using tables and cells, but you're fooling nobody.
Re:CSS Absolute Centering by jonahx on Saturday August 10, 2013 @09:23PM (#6193365)
+1. In what world, other than the current one fraught with our bizarre legacy, would you link the concept of vertical centering with the concept of "tables" and "cells"? How about: "display:non-idiotic-mode" and "display:layout-support-any-sane-person-would-expect", and now you can use "vertical-align"? A bit verbose but more accurate!
Re:CSS Absolute Centering by unclebucknasty on Saturday August 10, 2013 @09:26PM (#6193376)
Tables (or grids) are a very natural way of thinking about layout. Just about every webapp/site uses some sort of grid scheme as its layout model.

This is probably why the woefully layout-inadequate CSS had to include these hacks to mimic table behavior.

So, it's more like CSS is fooling nobody.

Re:CSS Absolute Centering by yesimahuman on Saturday August 10, 2013 @12:55PM (#6191733)
I've never really understood people who say CSS is horribly designed. In some ways, we are trying to apply desktop application design paradigms to something that started document or content oriented.

I can tell you that I'd much rather use CSS than Android XML layouts, or WPF, or adding layout containers a la Swing or AWT. It's simple, easily understood across disciplines, and very powerful. Elements of a pretty well designed system.

Re:CSS Absolute Centering by orangecat on Saturday August 10, 2013 @03:08PM (#6192259)
It's simple, easily understood across disciplines, and very powerful. Elements of a pretty well designed system.

On the other hand, it's 2013 and we're still trying to figure out how to center one element inside another.

In some ways, we are trying to apply desktop application design paradigms to something that started document or content oriented.

Which is exactly the problem. Web development today is a Turing tar pit, because we're using tools that were originally created for very different purposes. HTML is great for static documents, and lousy for apps. Javascript is great for attaching dynamic behavior to widgets, and lousy for large-scale software projects. CSS is great for consolidating style information, and lousy for layout. Yes, after over a decade of hacking by many smart people we've built up elaborate frameworks that sort of do what we want most of the time, but I wish we could have had more appropriate tools in the first place and been able to spend those resources elsewhere.

Re:CSS Absolute Centering by hamburglar on Saturday August 10, 2013 @06:20PM (#6192890)
> On the other hand, it's 2013 and we're still trying to figure out how to center one element inside another.

100% this. CSS is a very powerful tool if you know its quirks very well, and there are a lot of quirks. I know a lot of incredibly talented developers who can pick up any programming language or technology in no time at all, but still occasionally waste half a day circle-jerking with CSS trying to make it do something incredibly simple like center one box in another or baseline-align a couple of pieces of text.

Re:CSS Absolute Centering by peterhunt on Saturday August 10, 2013 @05:50PM (#6192805)
Agreed entirely that this is the problem today.

However we did have that (Java applets), and they didn't take off. I think the web did hit a bit of a sweet spot at the time, but it's time for us to build new technology on top of it. Personally, it's looking like asmjs, inline styles and translate3d divs to me :)

Re:CSS Absolute Centering by DougWebb on Saturday August 10, 2013 @02:41PM (#6192167)
Documents, in the real world, are full of layout that has been difficult to replicate in CSS. And to counter your point more directly CGI and the concept of web applications existed before CSS 1.0, so there was already need for application-style layouts when CSS was being designed.

Flexbox isn't the answer either. I had high hopes for it and I'm in the middle of redesigning a web application UI using Flexbox for layout, and I still can't do some basic things like have an overflow:auto content area that expands to fill the space between a fixed left-hand nav panel, a variable-height fixed header, and a fixed footer. I'm still stuck with a bunch of javascript and a window.resize event handler to measure some heights and adjust the sizes of my containers. Maybe the upcoming CSS grids will work, but it'll be another couple of years before support is wide enough for me to use them.

EDIT: I also wanted to say that I've learned xaml in the past few years, and that's absolutely not the direction I'd want CSS to go.

Re:CSS Absolute Centering by anonyfox on Saturday August 10, 2013 @02:37PM (#6192144)
i second this. CSS may be crap, but switching from frontend-development to swing-stuff makes me wanna hang myself after a few minutes. (And i worked with awt/swing/swt long before i touched CSS.)
Re:CSS Absolute Centering by lmm on Saturday August 10, 2013 @05:30PM (#6192745)
Try qt/smoke if you can. An API that actually makes sense and just does what you expect - or you can use QML, which is what HTML for applications ought to look like.
Re:CSS Absolute Centering by grandpoobah on Saturday August 10, 2013 @05:42PM (#6192782)
Wpf is fantastic, it is everything html could ever wish to be.
Re:CSS Absolute Centering by Skalman on Saturday August 10, 2013 @12:45PM (#6191687)
I agree that it's a disaster, but: Is there any better language? I feel that very few of the "native" variants have APIs that are simpler to deal with. (Of course Sass is much better than vanilla CSS, but it's basically the same if you strip away the sugar)
Re:CSS Absolute Centering by sker on Saturday August 10, 2013 @01:15PM (#6191826)
XAML is very well designed, not for the web though. It was designed from the ground up to be consistent with only one implementation, as opposed to CSS, which evolved over the years on multiple implementations. It can get quite verbose since it's XML-based, but at least what you code is what you get.
Re:CSS Absolute Centering by Skalman on Saturday August 10, 2013 @02:00PM (#6192005)
I feel that CSS is pretty well designed. The problem is that it has so many ways to do the same thing, and the fact that vertical and horizontal layout don't work the same way.
Re:CSS Absolute Centering by platz on Saturday August 10, 2013 @01:30PM (#6191895)
I've not built apps in xaml but I've heard the that its a PITA once your app gets to a certain size and complexity.
Re:CSS Absolute Centering by sker on Saturday August 10, 2013 @01:39PM (#6191928)
I agree, I just think it's well designed and consistent. Plus, CSS can also be a royal PITA, that's why I take refuge in back-end development when possible.
Re:CSS Absolute Centering by platz on Saturday August 10, 2013 @01:28PM (#6191885)
Show me a presentation language that is as flexible and powerful as CSS. Try styling something in a native gui language, or something like xaml, and I guarantee there will be many more curse words.

A lot of people who are shocked with the complexity of CSS aren't saying this after switching from another better GUI environment, they're getting into visual apps after doing backed work.

CSS is not perfect but I'll take it over previous presentation idioms any day.

Re:CSS Absolute Centering by lmm on Saturday August 10, 2013 @05:32PM (#6192757)
> Show me a presentation language that is as flexible and powerful as CSS. Try styling something in a native gui language, or something like xaml, and I guarantee there will be many more curse words.

You're on. I pick QML.

Re:CSS Absolute Centering by platz on Saturday August 10, 2013 @08:08PM (#6193152)
I must admit I'm unfamiliar, but at a quick glance it does look quite nice.
Re:CSS Absolute Centering by jonnytran on Saturday August 10, 2013 @03:40PM (#6192373)
What are some examples of previous presentation idioms you're thinking of? I think I can relate to what you're saying, but I'm trying to think of concrete examples.
Re:CSS Absolute Centering by saraid216 on Saturday August 10, 2013 @04:13PM (#6192487)
Cascading text styles are pretty well done, I think. The issue is entirely with box models, floating elements, scrollbars, positioning, z-index... you know. Everything to do with layout.
Re:CSS Absolute Centering by dminor on Saturday August 10, 2013 @03:38PM (#6192369)
> Short answer: CSS is just a horribly, horribly, terribly badly designed language.

On the contrary, it's the box model that's horribly designed. CSS is quite excellent.

We're long past the days of web pages being simple hyperlinked documents, but the browser's layout options haven't evolved quickly enough.

Re:CSS Absolute Centering by Keyframe on Saturday August 10, 2013 @08:49PM (#6193263)
Short answer: CSS is just a horribly, horribly, terribly badly designed language. It's the absolute worst.

16. When your language is nowhere near Turing-complete, syntactic sugar can be your friend.

Re:CSS Absolute Centering by CmdrKrool on Saturday August 10, 2013 @01:41PM (#6191932)
My journey:

See this well trafficked "CSS sucks"-type article, Ctrl-F the comments for John Nagle, be tantalized at the hints of how it could be so much better: http://www.raizlabs.com/blog/2006/09/25/ten-reasons-why-css-...

Look up "constraint-based layout" and more specifically "constraint cascading style sheets". You'll find papers such as this one: http://citeseer.ist.psu.edu/viewdoc/summary?doi=10.1.1.101.4... and this one: http://csis.pace.edu/~marchese/CS835/Lec7/mmJournal.pdf thoroughly describing such a system.

Find "GSS - Grid Style Sheets" at http://gridstylesheets.org/ , "an implementation of Badros & Borning's Constraint Cascading Style Sheets". This is still half on my todo list, but it seems like the real thing. The catch? Relies on Javascript.

Dream of a world in which this kind of system was built into browsers as the primary way of doing layout <insert Simpsons happy dancing people gif here>.

Re:CSS Absolute Centering by cousin_it on Sunday August 11, 2013 @02:30PM (#6195687)
Best comment in this thread IMO. Thanks! Some key parts from John Nagle's comments:

It’s not that CSS is hard; it’s that CSS is bad. (...) The worst problem with DIV-based layout is that the layout system is too weak. (...) There’s no way to relate a DIV to anything but its predecessor, its parent, or an absolute position. (...) Table layouts allow table cells which span multiple rows and columns. If all tables could do were simple grids of cells, the CSS approach might make sense, but tables are more general than that.

Re:CSS Absolute Centering by bane on Saturday August 10, 2013 @01:34PM (#6191914)
It's absolutely stupid and frustrating. Almost nothing in modern web design just works and it's because of both a badly written standard and badly written implementations.

I get it that HTML is supposed to be for content, CSS for layout and JS for programmatic logic, but the house of cards, duct tape, bailing wire and chewing gum that goes into making a web application is astonishing.

I almost think it would be easier for somebody to come up with an entirely different "web application/dynamic document layout" technology stack with a sane and well-working model all the way through, so that stupid basic things like vertical alignment don't go unfixed year after year after year and we end up with the teetering tower of hacks we have today. We pretty much know what we want out of the web, somebody should just go build it from top to bottom all over again and throw out the huge train wreck we have to deal with today. Sure it would take a while to catch on, but I bet a more efficient set of tools and display environments would rapidly catch on.

We've done it before and replaced older broken technologies with newer, why not do it again?

Re:CSS Absolute Centering by jared314 on Saturday August 10, 2013 @04:11PM (#6192482)
People compile languages with completely different ideologies to the JS object system, so why not compile a better layout model to the CSS box model. The CSS box model is going to be with web development, in it's current form, for at least another five years. So, why not use it as a compilation target.
Re:CSS Absolute Centering by Negitivefrags on Saturday August 10, 2013 @06:37PM (#6192932)
I'm not sure that CSS is has the "Turing completeness" equivalent for layout that a programming language like Javascript has for computation.

That is to say, it's not possible to create any conceivable layout with CSS alone. It might be possible if the thing spits out Javascript as well.

Re:CSS Absolute Centering by jared314 on Saturday August 10, 2013 @06:47PM (#6192959)
You don't need turing completeness to be a compilation target, but you have the right idea with additional javascript. For a box-glue model, similar to Latex, you would have to make some adjustments when resizing. The generated code might end up similar to what twitter bootstrap does it, but one step more abstract.
Re:CSS Absolute Centering by lutusp on Saturday August 10, 2013 @01:44PM (#6191941)
> I almost think it would be easier for somebody to come up with an entirely different "web application/dynamic document layout" technology stack with a sane and well-working model all the way through, so that stupid basic things like vertical alignment don't go unfixed year after year after year and we end up with the teetering tower of hacks we have today.

Yes, but if someone managed to create a logical, concise Web publishing standard that was something other than a can of worms, it would be a proprietary system, most likely patented. Which means no one would voluntarily adopt it.

The advantage of a public, open-source, no-one-in-charge system like we have now is that it's collaborative, democratic, and free. That's also its disadvantage.

For a classic counterexample, look at Apple's products -- they create much more consistent and usable products than the rest of the marketplace. But as many have said, Apple is a walled garden. If an Apple product happens to do what you want with no changes, then fine, otherwise you're out of luck.

Freedom is messy. Democratic technology seems always to veer toward chaos.

Re:CSS Absolute Centering by neilk on Saturday August 10, 2013 @02:14PM (#6192046)
It is not democratic. Democracies at least involve periodic check-ins with everyone who is affected.

The W3C isn't a town hall, it's more like the UN. At best they prevent the web from going back to the chaos of the mid-90s.

Re:CSS Absolute Centering by bane on Saturday August 10, 2013 @01:48PM (#6191955)
I wonder if this is a result of a broken committee process that should have had a benevolent dictator in charge of it instead.
Re:CSS Absolute Centering by lutusp on Saturday August 10, 2013 @02:09PM (#6192035)
> ... should have had a benevolent dictator in charge of it instead.

Like Guido Van Rossum in the Python world (with the title "Benevolent Dictator For Life"), who seems (so far) to manage his power well. But I think this is a rare exception to a well-known rule about arbitrary power.

Re:CSS Absolute Centering by lmm on Saturday August 10, 2013 @05:35PM (#6192764)
Look at what happened with Dart. No-one's going to try writing a better replacement for a web technology in a hurry after that.
Re:CSS Absolute Centering by dbettin on Saturday August 10, 2013 @07:32PM (#6193073)
What happened with Dart? The only thing happening with Dart is progress.
Re:CSS Absolute Centering by jasonlotito on Saturday August 10, 2013 @06:29PM (#6192912)
> I almost think it would be easier for somebody to come up with an entirely different "web application/dynamic document layout" technology stack ...

It was called Flash. Or Java applets.

See history.

Re:CSS Absolute Centering by ams6110 on Saturday August 10, 2013 @11:55AM (#6191493)
Purists will attack if you do this, but if you just want to get something done, using tables for layout often solves a lot of these headaches. Horizontal and vertical alignment of left, right, center, top, middle, bottom are quick and easy.

Edit: since you are a new developer, let me add that "ugly hackery" is what you quickly arrive at once you start doing anything of reasonable complexity (read: stuff that's actually useful). Handling the edge cases is what consumes most of the code in real production applications, and this is conveniently omitted from the beautifully clean code presented in tutorials and examples.

Re:CSS Absolute Centering by dylan-m on Saturday August 10, 2013 @01:46PM (#6191949)
One of the problems is we often have people doing web design was if it's print design. Find yourself a focused web designer who really understands the medium and, chances are, you won't run into this sort of problem. A good web designer understands that different browsers are going to have different capabilities, and build graceful degradation into the design. A good web designer knows that screens come in all shapes and sizes, and will avoid raster graphics and px-units wherever possible.

CSS, from my experience, makes it very easy to do web design the right way and very hard to do it any other way. It's just that the right way is often a little different from what people expect. If you accept that <i>the browser is the boss</i>, you'll be a lot happier, and incidentally your users will be a lot happier as well. The trouble is people coming from other platforms or mediums often expect 100% control, and for that it really doesn't hold your hand.

Re:CSS Absolute Centering by chestnut-tree on Saturday August 10, 2013 @01:57PM (#6191990)
"...the amount of hackery that goes into making webpages look the way web designers want them to is astounding."

I totally agree. For example, the CSS box model sounds so simple and elegant at first, but when you add dozens of styles and elements to your page, the interaction between different styles can quickly become horribly messy no matter how disciplined you are with your CSS code. Beyond a certain number of styles, CSS inheritance turns into a black art.

CSS simply doesn't scale well for anything beyond relatively simple pages. A huge part of designing web pages is layout and spacing and yet positioning and spacing elements remains ridiculously messy and convoluted (even with CSS3).

You could also argue that tools like SASS and LESS are in effect sticking-plasters for inadequacies in CSS.

I know hindsight is a wonderful thing, but if we were designing CSS today from scratch, I think it would be designed very differently.

Re:CSS Absolute Centering by babby on Sunday August 11, 2013 @11:37AM (#6195183)
CSS could be redeemable if; the box model defaulted to box-sizing: border-box;. If vertical-align and margin: auto (or variants) worked with variable heights and widths, and on all elements. If percentages of heights worked inside all elements.

It seems like flex-box fixes a lot of this, but at the same time, it could be so much easier.

You're right though. CSS would be so much different and so much more gloriously painless to use. I can even imagine a better styling engine allowing for applications like macaw, dreamweaver to actually generate properly good CSS and thus building sites with a GUI would finally be plausible.

Re:CSS Absolute Centering by thurn on Saturday August 10, 2013 @11:58AM (#6191510)
We're working on solving these problems with new tools (flexbox in this particular case), but it takes time for those tools to become widely usable. You can look at e.g. Google's Polymer project for a glimpse at the vision for web programming in the future.
Re:CSS Absolute Centering by kmfrk on Saturday August 10, 2013 @11:54AM (#6191484)
90% of webdesign is dealing with errant behaviour.

It's why it's so frustrating when people treat front-end design with disdain as something trivially easy. Of course, if you only decide to serve the newest version of Chrome and Safari, it can be easy to remember that there people out their who don't - or can't use them.

Re:CSS Absolute Centering by syncerr on Saturday August 10, 2013 @12:26PM (#6191605)
> webdesign

It's web development you're referring to.

Re:CSS Absolute Centering by jiggy2011 on Saturday August 10, 2013 @12:34PM (#6191643)
Without wishing to descend too much into semantics the accepted definitions (at least within the industry) seem to be that "design" is basically Graphics/Layout (so includes HTML/CSS) and development is programming (either client or server side).
Re:CSS Absolute Centering by matthewmacleod on Saturday August 10, 2013 @01:22PM (#6191861)
I don't agree. Design is design, development is split into front- and back-end specialisations. Some developers straddle both, but there are few people who are both (good) designers and developers. I don't know of anybody within the industry who would refer to a front-end developer as a "designer."
Re:CSS Absolute Centering by jiggy2011 on Saturday August 10, 2013 @01:46PM (#6191948)
It depends if you are programming or simply describing page layout. Front end development could also include things like Javascript. There are plenty of designers who are not Javascript programmers but who can use CSS etc.
Re:CSS Absolute Centering by simonw on Saturday August 10, 2013 @03:19PM (#6192298)
HTML and CSS are programming.
Re:CSS Absolute Centering by jiggy2011 on Sunday August 11, 2013 @05:29AM (#6194472)
You could probably argue that in a technical sense but it's a person who works with HTML/CSS but not say JS etc would probably be considered a designer more than a programmer.
Re:CSS Absolute Centering by simonw on Monday August 12, 2013 @06:43PM (#6202678)
I've worked at a bunch of different companies (Yahoo!, The Guardian, various smaller companies) and in all of them the "designers" were the people who did the visual design using Photoshop and Illustrator - those people rarely if ever wrote HTML and CSS, and almost never to production level standards.

The people writing production-ready HTML and CSS were known as "web developers" or "client-side/front-end engineers".

Re:CSS Absolute Centering by dsego on Saturday August 10, 2013 @12:00PM (#6191514)
Some would argue that whole doing the web with markup and stylesheets thing is completely wrong (Bret Victor comes to mind). And I tend to agree. CSS is a hack, heck, HTML itself is a hack.

Some material:

http://www.raizlabs.com/blog/2006/09/25/ten-reasons-why-css-...

http://diveintohtml5.info/past.html

Re:CSS Absolute Centering by blhack on Saturday August 10, 2013 @12:10PM (#6191546)
I'd love to know why just using tables is wrong.

The user gets what they want, the designer gets what they want, and the only people unhappy are some purists.

why? what about this is wrong?

Re:CSS Absolute Centering by ahallock on Saturday August 10, 2013 @01:12PM (#6191816)
I would have agreed with you maybe 2-3 years ago from a pragmatic standpoint, but the most compelling reason now for not using tables for layout is that they're not compatible with responsive web design. Table cells don't stack and can't be reconfigured like block-level elements.

You can get away with using "display: table-cell;" and the like inside components that are independent of responsive requirements, though.

Re:CSS Absolute Centering by jsiarto on Saturday August 10, 2013 @12:24PM (#6191590)
Tables are for tabular data--designing with HTML/CSS isn't perfect, but using tables for layout is an even less-elegant solution. It leads to a markup soup of nested tags and tables and difficult-to-maintain codebase. Good design and good markup go hand-in-hand and often you need to strike a balance between flashy visual design and solid underlying structure. This is also why visual designers should understand how their designs get implemented in HTML and CSS--it will create a restraint and limit the amount of "hacks" you have to do to make a design work.

Also remember that not everyone views the web in a browser. Having well structured markup helps those that use screen readers or alternate methods of browsing the web.

Re:CSS Absolute Centering by bonaldi on Saturday August 10, 2013 @12:30PM (#6191626)
"Good design and good markup go hand-in-hand"

I don't think this is true any more than "good print design and good postscript go hand-in-hand".

I don't think tables are the right way either, but they're too often the pragmatic way until CSS gets dramatically more expressive.

The "restraint" you're talking about is not something designers should have to accept —- not least because CSS appears to be being developed with insufficient concern for what designers would actually like to be able to do. If it wasn't, vertical alignment would have arrived long ago.

Re:CSS Absolute Centering by mannix on Saturday August 10, 2013 @01:02PM (#6191763)
Table-based layouts will bite you down the road. Ever try to make a div that completely fills a td? Ever try absolute positioning in a table? It is tempting to use them because they are so simple and "just work", but they come with unforeseen consequences.
Re:CSS Absolute Centering by dspillett on Saturday August 10, 2013 @12:43PM (#6191679)
A key problem with table based design is accessibility: while table based designs aren't automatically a problem for screen readers and such, a great many are.

It also makes it far harder for other user agents to make the design fit in small spaces: many table based designs are completely unusable on mobile devices for instance. While the alternative might still not look nice in such an environment, it is more likely to not be completely impractical to use.

Of course if you are presenting something that naturally fits in a tabular structure, tables are the thing to use as that is what they are designed for.

Re:CSS Absolute Centering by maxhowell on Saturday August 10, 2013 @12:51PM (#6191710)
Everyone who says using tables is wrong, is wrong. The only issue as far as I'm concerned is it is tedious to style tables, and you have to have <table><tr><td> all the time which is tedious to work with. All the other arguments are perfectionism. Even the accessibility argument is nonsense nowadays, it amazes me people are claiming screen-readers haven't advanced in 10 years. TEN YEARS AGO screen readers sucked with tables.
Re:CSS Absolute Centering by Achshar on Saturday August 10, 2013 @12:41PM (#6191667)
Because tables were not made for layout. They were made to present data in tabular form, and it's still perfectly acceptable to use table tags to show data. But using tables for layout is like chaining a bunch of cars to make a makeshift train, both can be used to travel, but a train was made to move a large number of people, and cars can only move small number of people. There are better tools available. That and tables result in some very ugly code structures. And see the upcoming flexbox model. I have tried it and it really feels more apt, a lot better than using floats and a hell of a lot better than tables when it comes to satisfying, good and perfectly predictable symmetric code.
Re:CSS Absolute Centering by flomo on Sunday August 11, 2013 @12:08AM (#6193797)
Actually, the original W3C proposal for tables specifically mentioned using them for layout. I can't find a working link, but there's also a RFC:

The HTML table model has evolved from studies of existing SGML tables models, the treatment of tables in common word processing packages, and looking at a wide range of tabular layout in magazines, books and other paper-based documents.[1]

It was only later when table layouts began to be discouraged.

[1] http://community.roxen.com/developers/idocs/rfc/rfc1942.html

Re:CSS Absolute Centering by chrislomax on Saturday August 10, 2013 @12:21PM (#6191575)
I'm no purist but I am in the mindset, "you wouldn't use a fork to eat soup".

I do agree though that it is a pain when something is easily achievable in tables but doesn't work in normal CSS. Vertical alignment being one of them.

What does annoy me is when you see people creating "CSS table" systems. I'm not being funny but that is just plain stupid. I saw a whole project dedicated to replicating the behaviour of a table.

I started developing when tables were fine to use for all layouts and I feel CSS was adopted as a layout too early without some very basic things being answered.

Re:CSS Absolute Centering by wmkn on Saturday August 10, 2013 @12:21PM (#6191577)
If it solves your problem there is nothing wrong with it. However, tables are considered problematic because they encode the layout of the page in the HTML. Ideally, you would semantically structure your page using HTML and add style and layout using CSS. This way of working would allow for maximum flexibility - you can restyle your page without ever touching the HTML. If you use tables it becomes much more difficult because the table already adds a certain fixed layout.

Unfortunately the real world hardly ever works like this.

Re:CSS Absolute Centering by ahallock on Saturday August 10, 2013 @01:19PM (#6191844)
I think people have gone too far with this mindset. I develop pages using a mostly semantically structured approach, but I'm not afraid to sprinkle layout-only elements where they make sense, especially when using grids.
Re:CSS Absolute Centering by simonw on Saturday August 10, 2013 @02:40PM (#6192160)
On a purely practical level, using tables for layout makes it much harder to implement a responsive design where elements are arranged differently at smaller screen sizes.
Re:CSS Absolute Centering by cruise02 on Saturday August 10, 2013 @01:09PM (#6191798)
> ...the only people unhappy are some purists.

Right. Purists like blind people who access your site with a reader, and Google's page crawler.

Re:CSS Absolute Centering by txutxu on Saturday August 10, 2013 @01:23PM (#6191868)
Google is the first one using tables for layout, since they started until today.
Re:CSS Absolute Centering by nostrademons on Monday August 12, 2013 @05:29AM (#6198376)
Google (Search) hasn't used tables for layout since 2007.
Re:CSS Absolute Centering by cruise02 on Tuesday August 13, 2013 @11:16AM (#6206222)
How Google displays their own search results (tables or divs) is irrelevant to how their crawler interprets everyone else's pages.
Re:CSS Absolute Centering by thekingshorses on Saturday August 10, 2013 @01:20PM (#6191850)
Just wondering. Why did you decided to become a web developer after so many years?

Usually developers try to find a way to solve the problem because they are engineers and that is what engineers should do. HTML, CSS and JS wasn't invented to what it has become today. It has evolved thanks to people like you and me who has find ways to use to our advantage. Example AJAX was existed since dark ages (IE5+) but no one used/knew about it. Google used that in google maps in 2004. Now, pirates are using it in usenet/torrent applications (utorrent, sabnzbd, sickbeard etc), or 3d rendering in the cloud (http://home.lagoa.com/).

If you are waiting for something better to be found, i think you will have to wait long time. There is nothing on horizon that is as simple as HTML.

For me, hardest part is in the web development is to deal with designers and product managers.

Re:CSS Absolute Centering by gamegoblin on Saturday August 10, 2013 @05:21PM (#6192712)
I'm not a web developer. I just wanted to add a bit of web development skills to my set of abilities so I've been learning the Django framework and the nuances of HTML/CSS/JS.
Re:CSS Absolute Centering by steveax on Saturday August 10, 2013 @03:56PM (#6192428)
We sorta had that already. It was called Flash (or Silverlight, etc. pick your poison) and while it was easier for authors to do many things, it sucked for users in more ways than I can count.
[deleted]
Re:CSS Absolute Centering by dm2 on Saturday August 10, 2013 @11:53AM (#6191478)
And no longer have to support IE7 (if you're lucky).
Re:CSS Absolute Centering by rimantas on Saturday August 10, 2013 @01:46PM (#6191947)
Be glad you did not have to do this when IE5/6 was still around and Firefox was starting to go strong. Sites with sole purpose todocument all the hacks you need to do to force IE to behave a still around.