CSS Layout: Soon Good Enough for GUIs
One of the sore points of Ajax has always been layout: CSS is great for document layout, but sucks at GUI layout. Where Java layout managers such as the grid-based JGoodies FormLayout (PDF) work really well and can do things such as “make this grid cell as narrow as the content allows”, CSS currently needs absolute length specifications.
Furthermore, letting an element fill out all of the available space is really tricky, especially when done vertically. Thus it is no wonder that layout was ranked high on the OpenAjax browser wish list. Thankfully, the W3C is hard at work at fixing this problem and it seems that all the major browser vendors are on board (if you look at the editors).
- CSS Template Layout Module: lets one specify grid-based layouts in a really neat ASCII-art-like way. Go to “CSS Template Layout demos” to see examples.
- css-template-layout: implements template layout in current browsers via JavaScript.
- Flexible Box Layout Module: is “based on the box model in the XUL user-interface language used for the user interface of many Mozilla-based applications (such as Firefox)”. To get a grid, you need to nest several boxes. I prefer template layout's more direct approach.
- CSS Grid Positioning Module Level 3: mainly for document layout (multi-column layout etc.).
According
to my sources, the W3C will try to consolidate these three proposals as
much as possible, but might have to keep two, because GUI applications
and document layout have such different requirements.
- Login or register to post comments
- 5837 reads
- Printer-friendly version
(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)




Comments
Jacek Furmankiewicz replied on Mon, 2009/07/20 - 6:49am
CSS for layouts? Instead of the almighty MigLayout?
You have to be kidding. MigLayout wipes the floor with all of these verbose XML-based approaches. I'd love to see MigLayout ported to HTML instead.
Charlie Hubbard replied on Mon, 2009/07/20 - 11:36pm
I think W3C should freeze adding more tags to <html>. HTML is great for documents, a little overloaded/over engineered, but if we stopped I think html would be nice when we need to create documents.
Instead of adding more tag soup to html to support application layout features, why not surround the <html> element with an <app> element. Any <app> element could embed a <html> document element that behaves just as <html> does today. This would also make it backwardly compatible too. The difference is <app> changes the default layout from document flow to application layout. Where all of our <div> behave more like you'd expect in an application. Just as every other client platform, other than HTML, behaves with parent-child nesting, and children coordinates are relative to parent's coordinate system, etc. I can position elements anywhere in it's parent without absolute/relative css magic. I can align two element's edges to create grids, etc.
If we started thinking like this things become really simple, and <html> is just another fancy set of tags that define a different layout to do document based things. Make it simple to understand and the browser manufacturers won't screw it up like they did css. Starting from the standpoint that CSS as it is works is a broken assumption. CSS is horrible to use and it's terrible un-user friendly as an application layout language. Notice how adobe has abandoned it in Flex because it doesn't work well for complex definitions. If you want to build the next greatest thing you'll need to ditch CSS because it's not flexible enough to support tomorrow's requirements.
Axel Rauschmayer replied on Tue, 2009/07/21 - 9:09am
in response to: Jacek
Axel Rauschmayer replied on Wed, 2009/07/22 - 5:23am
in response to: middlec
Nez Arem replied on Wed, 2009/07/22 - 10:42pm