Why I consider CSS to be a horrible design language.
Writing CSS (CSS2) never ceases to amaze me. Whether it’s tweaking this blog, trying to re-theme a php app, or simply experimenting in the Web Developer Extension, I am always struck by how difficult and confusing it is to try to implement very simple design patterns.
Be it centering objects, making layouts use the maximum amount of space, or simply trying to use floats properly, I am always amazed by how seemingly obvious code does not work the way I should think it does. It seems rather silly to me that such a language would be designed such that web designers must resort to specialized recipes to deal with seemingly simple and common page layout designs. While powerful, CSS seems to become more and more a search for hacks and snippets to make many designs possible. Browser support is also an elusive and secretive gem; unless explicitly stated, what works in one browser will probably at some point fail mysteriously in another.
Tonight, my appreciation for the language fell to a new low. In the mid-day, thinking about my page layout, I decided that I wanted thumbnails posted from my gallery to be aligned to the right of the post, so that post text can wrap around them on the left. I figured this would be a relatively simple fix; I just needed to float the image class to the right and see what happened.
Well, not so fast. I had failed to remember that images when floated will (without a clear property set on a following element) essentially make the following layout flow through and under the image, leaving the image on top of the footer and the title of the following post. After a little searching and reading, I realized this mistake and added the appropriate clear: right; to the .post-footer class. The footer should now make appropriate space for the image in the post. Simple, right?
Again, not so fast. After putting in this little tweak, I found the first post on my page (without any image) being followed by a long swath of whitespace, assumedly caused somehow by my float: right‘d sidebar. Why was the browser making a whole bunch of space for something that wasn’t there? I may never know. Well, debugging this would prove to be a nightmare, so I soon got tired and decided I needed to do some research. I googled CSS float clearing techniques, searching for some trick to make space for the image without involving other floats. Well, I ended up finding this quirksmode.org article describing a trick for making float space work without needing the clear property.
Well, how about that? Reading it worked on most browsers, I quickly tried this new overflow: hidden trick on my .post-content div, and looked to see if it would work. Well, at first attempt, it didn’t. But it was close. This time, space was being made between posts for the image to fit in. However, the footer was still flowing through, underneath the image. This was relatively easy to fix, after I added back the clear: right; line to the footer div, this worked too. The blank space following the top post (which is why I seached for this trick in the first place) disappeared. At this point I really didn’t care why, and was glad that it did.
Then I noticed some mysterious padding being added under the titles of posts. This was directly associated with the existence of the overflow: hidden statement. About a line of space was being added under the titles for reasons unknown to me. I tried hard setting any margins and padding I could think of to 0 (most were already), yet still, this mysterious and unexpected space was being made. After fiddling with it for a while, disappointed that the trick might not work, I tried moving overflow: hidden to the parent div, .post. This worked like a charm. Everything was working as it should have been: space was being made for right-aligned images, text was flowing around them, and there was no longer any weird quirkiness being wreaked upon my page layout. Finally! 
This experience I had tonight illustrates my primary frustration with CSS: it makes no sense for achieving simple design tasks. Certain assumptions about the purpose and performance of properties never seem to work out entirely as planned. My attempts at putting an image on the right required an understanding of the float layout system, the subtleties of clear usage, and even an arcane trick barely documented and not well-known - at least not very accessible to me.
Further, this impacts the sanity of CSS as a programming language: as a designer and a programmer, I expect that properties and directives will just work, in a way not so far off from the way they are documented to. In my experience with CSS, and in this example, the subtlety and lack of documentation in getting things to work as intended required so much more fiddling, guesswork, and raw googling than I ever expected to do. Also, pages become so big and complex that when dealing with many layout bugs, there is usually not an obivous quick fix.And I am simply using CSS like a programming language. I don’t even want to imagine the ways one would try to create a GUI for representing these difficulties in a WYSIWYG environment.
When attempting to represent a graphical layout using programming directives, I understand that it is very hard to craft a language that is both simple to use and powerful in it’s creative offerings. CSS really achieved a lot in terms of power in crafting web designs, and especially in controlling the typography used. However, the current state of utilizing CSS in web design is both an exercise in frustration and confusion, as the subtlety of the effects of CSS directives make it (at best) difficult to debug, and the arcaneness of the techniques used takes the considerable learning curve of CSS and shoots it through the roof. 
After dealing with CSS a reasonable amount, I can only wonder at the hoops professional web designers must leap through in negotiating between the limitations of their environment and the needs/desires of their customers. As an open source and Linux enthusiast, I make minimum effort to accomodate poorly compliant browsers. I’d rather not think about the far more trouble one has to go to to ensure such compatibility. Heck, it would take so much time to really get fluid with the medium that suddenly, the role of the professional web designer makes so much more sense to me! 
About: I am a digital artist and computer geek with interests in Linux, open source design programs, and saving the world. You will find me blogging here about art, life, technology, and other mildly amusing things.
RSS 2.0

I’ve been working with CSS for about three years now, and it’s become fairly simple. But mainly I’ve learned that designing around these quirks is often the best way to go, making compromises in the original design to accomodate what works. I’ve also found that the more hacks you put in, the worse a design becomes to manage.
Just looking at your code, briefly, I’m wondering if you weren’t seeing such problems because your thumbnail is encased inside a paragraph tag. I know that might be a tight spot to get out of due to Wordpress automatically putting it in there, but it might help. Also, when floating
display:inline;is your best friend.The other thing I’ve learned is that, be it CSS or PHP, it’s always the smallest, seemingly insignificant thing that’s the problem. The rest of the time its IE.
Comment by human-powered — May 12, 2006 @ 11:02 am
Hi,
I came across your blog while browsing the net for CSS related matter. And I truly like the design of your blog. It is very pleasing to the eyes- not like those you find which are really hard to read or with garish colors.
I wonder why you dislike CSS. I would say it is the best thing that has happened to web design. In my opinion, CSS gives a lot of benifits..
1) Seperate content from design.
2) Reduce the size of the webpage (throw out tables for a change and use divs)
3) One can let ones imagination fly and re-design the entire blog by just editing the css file.
4) Standards compliant which makes it easier to display the same webpage on web browsers, screen readers and even PDAs. Only use different stylesheets for each devices.
5) I could go on and on …
If there is a drawback, it is with the web browsers and not with CSS. But I believe the gap is closing fast and the latest Opera 9.0 (to be released on 29th June) is said to be CSS 3 compliant.
BTW: I see that you are hosting on nearlyfreespeech.net. If you don’t mind my asking, how much do you end up paying for hosting per month and did you register the domain name with them ? And how much will it cost you if your site gets slashdotted
?
Comment by Ravi — June 18, 2006 @ 7:17 am
Hi Ravi,
), and neglected to mention some of the great things about CSS. I must say that I agree with everything you’ve listed here. Without CSS, the web would be very different from the web as we know it - and in terms of it’s structural relation to XHTML and other web technologies as a whole I think it’s a very clever system.
Thank you for your thoughtful and interesting comment. I realize that I wrote this post in the midst of some CSS-related frustration (such feelings pass
However, my critique pertains to CSS and it’s role as a design language. No language is perfect, and any attempt to create a system that may suit the artistic and technological needs of the greater Internet is an incredibly difficult task.
I would argue that there are some important parts of the language that could be done better. My primary annoyance is in the ways CSS positioning/placement work. I recall reading an article about a year back of some of the more prominent web designers expressing their pet peeves about CSS. The one that stuck with basically asked why CSS has no simple “expand” property: a way to tell a block to take up all of the space available to it. Imagine if designing in CSS worked more like GTK’s “pack” model: if elements consistently filled up all of the area available to them, and then you could add on horizontal and vertical splitters that would proportionally or statically divide the space. There are ways to approximate this in CSS, but no ways with the elegance I’ve seen in my limited working with GTK. This Yahoo framework is a bit intriguing in the limited versatility it provides.
I totally agree with you about the problem of the web browsers — though I wouldn’t say it’s the only thing in CSS that could be improved. The continuing annoyance of varying support and compatibility (and usually for the cooler features!) in web browsers really tends to put a cap on the experimentation one may freely apply to their designing. It makes me feel a lot less assured in trying new things out and taking risks. It’s such a disappointment to find that neat little trick you applied the week before before totally breaks things in a browser you hadn’t tested it against.
On NearlyFreeSpeech: Looking at my records for the month of May, I was charged $0.43 for hosting and $0.31 ($0.01 per day) for the domain privacy service. I did register my domain name with them, which took me down another $7 (but came online almost immediately). After about 2 months with the service, out of the $15 I put in, I still have over $5 left in my account. Keep in mind that this is for a modest blog/personal space. I’d definitely give them a recommendation. NFS is really the type of service get the most out of with some command line Linux/BSD/MySQL chops. From the looks of your blog (looking good!), this should be no problem. Their estimate for a slashdotting is around $10. While I have a feeling this is a bit low, this surely is a small price to pay for that kind of exposure!
See this FAQ for their statement about it.
Comment by chromakode — June 18, 2006 @ 1:11 pm
Hi again,
After pondering on what you have said, I guess there is always scope for improvement for any technology. And CSS is evolving all the time. I am actually looking forward to a better web experience in the future.
And thanks for sharing the details of your hosting expenses with me. Nearlyfreespeech looks really interesting. And their hosting fees are also good. When I decide to move to my own domain, I will give it serious thought.
Comment by Ravi — June 18, 2006 @ 10:42 pm
just frustrated, so rez’ing this post
Comment by Anonymous — January 13, 2008 @ 2:48 pm
I wholeheartedly agree - CSS is just a PITA.
Comment by Sosh — March 16, 2008 @ 3:43 am