0

After asking this question, it appears that a lot of CSS hacks and tricks are needed to achieve something that simple. People have said that CSS is broken.

So I wonder now, if not CSS, what are some alternatives to creating advanced html structure and markup/layout?

Are we left with tables and framesets? Or is there something else?

Community
  • 1
  • 1
Tom
  • 8,536
  • 31
  • 133
  • 232
  • 2
    after reading your previous question, this looks more like you ranting than an actual legitimate question. -1. – gehsekky Dec 16 '09 at 21:07
  • I'm sorry that's how you see things. I am in fact interested in what people do use. Thus is in no way me ranting, I would do that elsewhere - if at all. – Tom Dec 16 '09 at 21:12
  • 3
    Make sure that you understand the three CSS positioning models before you criticize CSS: `http://www.brainjar.com/css/positioning/default.asp`. Your previous question suggests that you have not completely understood these yet. – guns Dec 16 '09 at 21:12
  • 1
    Guns, I am not criticising CSS - it's those people who answered my previous question. Notice the "apparently" in my question. :) – Tom Dec 16 '09 at 21:13
  • @tom: Response comment for you in Bryan's answer. – Carl Smotricz Dec 16 '09 at 21:45
  • Your actual problem was that you added borders and expected them to be taken into the specified width and height. This is not true according the W3 box model. Interesing detail is however that the (flawed) MSIE box model suits your wish. – BalusC Dec 16 '09 at 21:53
  • That's not what I expected actually. Try substracting the borders from the numbers, it won't fix the problem. If you think it does, I'd appreciate a working version as an answer there. So far, noone managed to do it yet without hacks or tricks. – Tom Dec 16 '09 at 22:04
  • Frankly I don't find CSS that difficult and the hacks are consistent when you get to know them. – DM. Dec 17 '09 at 19:11

9 Answers9

12

CSS is broken, but the best way is still CSS.

While CSS itself may have flaws and missing features and be generally crappy, and while it may not work the same in every browser, it's still the best tool for the job. Its still an extremely flexible tool, albeit a slightly broken one.

ShZ
  • 6,518
  • 1
  • 26
  • 22
10

Generally speaking, CSS is not the problem. Rather it's those authoring the CSS that need help. Write standards-compliant code, use a standards doctype, don't depend on experimental features, and carefully implement progressive-enhancement.

Following these simple rules will ensure that your projects will play well with various browsers, and behave in a manageable way. Most issues that frustrate developers are the direct result of those developers not doing one or more of the previous suggestions and not the result of language-designers or browser-vendors failing at their jobs.

Programming and Web Development are not trivial careers; they require constant studying and self-improvement. Unfortunately we developers are often times rushed and aren't able to give our profession the care and nurture that it needs, and this creates more problems than we can comfortably handle.

Sampson
  • 265,109
  • 74
  • 539
  • 565
  • 2
    Those who develop CSS or who use CSS? If the latter, you might want to check out the question posted in the original post. Apparently, noone there managed to solve the problem without using hacks, tricks or different methods for each browser. – Tom Dec 16 '09 at 21:07
  • @Tom: check my solution posted for that question... it works in all browsers with no hacks. – Tor Valamo Dec 16 '09 at 21:23
  • Thanks, but when the text box's content exceeds the original height, the box does not dynamically grow with the content while it should (the same applied for other suggestions done earlier). – Tom Dec 16 '09 at 21:28
  • 1
    There are entire classes of layouts that CSS does not enable, and which no amount of "rethinking" and pondering CSS will resolve. A subset of these problems can be addressed using tables, so it's not like they're horribly arcane. I downvoted you because you deny this fact. – Carl Smotricz Dec 17 '09 at 06:29
  • If you enjoy a CSS challenge, I look forward to your solution to this question: – Carl Smotricz Dec 17 '09 at 06:33
  • @Carl, I don't deny that some things aren't possible. I deny that this therefore means "CSS is broken." – Sampson Dec 17 '09 at 13:30
  • 1
    -1 Your comment that those who write CSS are broken is highly inflammatory, especially when it is generally accepted in the industry that CSS is flawed which is evident from the features in CSS3. – Luke Puplett Dec 15 '10 at 16:56
  • @Luke My comment isn't meant to be "highly inflammatory." My point is that 99% of the complaints I hear regarding CSS are actually problems with the approach taken, and not with the potential of the technology itself. – Sampson Dec 15 '10 at 17:07
  • Many issues with CSS are the fact that its behavior is not implemented in a standard way, even across grade A browsers. There are a lot of cross-browser quirks that even experts have a hard time with, and I'm not just talking about IE. CSS and JS authors have it rough sometimes. – Wesley Murch Dec 11 '12 at 03:17
3

I would say the recommended way is to stick it out with HTML (possibly HTML 5 markup) and wait for CSS to get fixed with CSS3. I wouldn't suggest going back to tables and/frames.

If you need more layout control, consider doing your website in another technology, such as Silverlight or Flash

rossipedia
  • 56,800
  • 10
  • 90
  • 93
  • +1 for the first para, -1 for suggesting considerably heavier technologies when DHTML might do just fine. – Carl Smotricz Dec 16 '09 at 21:07
  • Do you have any resources explaining how to develop basic structures with pure html while not using tables or frames? For example, a header on top, a menu and content window in the vertical middle and a footer which will always be at the bottom. Of course the height of the content window would be dynamic to the content. – Tom Dec 16 '09 at 21:10
  • I didn't get a useful answer, but I was sent a link to a site ridiculing table users. Please read *both* my answers (and the following comments) here: – Carl Smotricz Dec 16 '09 at 21:45
  • @Carl Smotricz: Ouch. It just seems to me like he needs finite, exacting control over the layout. Even when using DHTML/Javascript, there's still all sorts of idiosyncrasies and peculiarities to deal with. Yes, even when using something like jQuery/Prototype/Moo/etc... In that case, another technology like I suggested would be a perfectly valid solution, given the requirements, and would probably make it much easier on the development side. – rossipedia Dec 16 '09 at 23:02
  • I hate Flash and Silverlight, both as a dev and a user. That explains my animosity (sorry). But enough of that, I'd like to clear up a misconception here: Many of the things you can't do in CSS are layouts easily addressed by different, more versatile rule sets. Case in point: GWT. They implement the equivalent of various Swing layouts in HTML with CSS, stooping to tables when they have to, and thus make many "interesting" layouts possible. Much improved since recent ver. 2.0 . Recommended! – Carl Smotricz Dec 17 '09 at 06:23
  • Well, I'd definitely check that out if I didn't have a pathological aversion to Java haha. Thanks :) – rossipedia Dec 17 '09 at 18:19
2

If by "advanced" you mean very complex like desktop application UIs, then yes, sooner or later you will have to use tables.

It is considered that using tables for design is wrong, but since we figured out CSS is "broken", then why would it matter anyway? You're apparently out of options.

It is a pity that boys responsible for development of HTML and CSS have made mess of the things. Web development could have been in advance by leaps now. We can only hope it will get streamlined in the next few years with HTML5, CSS3 and browser improvements.

  • 1
    Because good CSS is MUCH more efficient at styling site-wide than anything else. Use CSS where possible, but don't be afraid to fall back to tables where necessary. – MindStalker Dec 16 '09 at 21:09
  • Just to add detail: Tables allow you to specify a layout where column width depends the relative amounts of space needed in each column. Since column contents can themselves be deeply nested or simply large, etc, this is potentially a devastatingly expensive operation - any re-layout may end up being recursively complex. To address performance-related whines, the CSS folks didn't want us playing with that particular toy, so they effectively simply took it away from us. Performance problem solved :) – Carl Smotricz Dec 16 '09 at 21:53
2

CSS is not "broken" simply because it doesn't work the way you think it should. Looking at your previous question, your premise is that what you did was correct, and that margin-bottom wasn't doing what it should. This is a faulty premise. Respectfully, your understanding of the CSS box model is flawed.

I answered your previous question there.

stephenhay
  • 2,824
  • 24
  • 25
  • 1
    If your car windscreen leaks and you took it in for repair, would you be happy if they told you that your understanding of their windscreen is flawed? British car-makers did have this attitude for years, "Ah, they all do that." This is why the UK no longer makes cars. – Luke Puplett Dec 15 '10 at 17:16
1

Many interesting layouts are possible with CSS. As the share of IE6 in the world is declining, the compatibility situation is slowly improving, too. You can also make a lot of browsers behave better by putting proper headers on your HTML.

For some intended layout cases, the answer I get to questions like yours is often "change your design".

Some layouts can be achieved using tables to partition vertical and horizontal space. I always get flamed by the CSS purist zealots when I suggest this, but they usually don't have any better alternatives to offer.

That said, it's a good idea to use tables as little as possible, as this use doesn't correlate well with their intended meaning and purpose. Consider tables an emergency hack for those cases where CSS solutions would be a lot more hackish.

Carl Smotricz
  • 66,391
  • 18
  • 125
  • 167
1

Hate to burst anyone's bubble but all of HTML is styled with CSS whether you use CSS directly yourself or not. You can view the internal CSS styling of many of the browsers including how it style tables and frames. In Firefox, look in the res folder for html.css

Rob
  • 14,746
  • 28
  • 47
  • 65
0

If not studied correctly CSS can appear broken. It is simple to learn but a little tricky to master. Maybe run through some more tutorials and get a better grasp on the box model and such before writing it off.

That being said CSS still angers me on an almost daily basis but it is still the best.

Davey
  • 1,314
  • 6
  • 22
  • 37
0

Here are some alternatives:

  • image maps
  • pre formatted layouts
  • table formatted layouts
  • XSL-FO=>HTML formatted layouts
  • object formatted layouts

References

Community
  • 1
  • 1
Paul Sweatte
  • 24,148
  • 7
  • 127
  • 265