One may or may not like round corners. That, after all, is a matter of taste. But I somehow fail to see what’s wrong with using JavaScript to artificially round corners on some divs. Could you enlighten me?

Before sounding like this world’s most complete dodo, allow me to say upfront I am very aware of a number of issues: JavaScript rounding contraptions add weight to a page, will not work on all browsers and may even throw an error in some, could, if poorly implemented, botch your page’s layout and, finally, add a bunch of useless markup to a page… only to satisfy a rather pointless trend.

In the following entry, it is assumed you want rounded corners. For the record, I, FJ, like rounded and square corners about just as much and have no particular bias towards any. I do believe however a well-designed page can mix both and, in many cases, should mix both so as to provide proper visual information to its readers.

Yet, the more I read about the “proper” ways to implement them with CSS, the more I wonder. We all know the “proper” way is CSS3 and that it will have to wait — a long time. CSS2 provides us at best with vendor-specific extensions or unsupported declarations. Meanwhile, we all strive to deliver round corners that are vaguely compatible with Internet Explorer (because not everyone uses Safari) and don’t litter the code.

Most rounding corners use JavaScript libraries such as Behavior, allowing them to round divs based on a simple declaration of class — ie you can instruct the script, through a single line, to round all divs belonging to a certain class or within a certain container on the page. Of course, when the script kicks in, it will produce some extraneous markup but your actual raw document is clean. If you add that single line of JavaScript through a lone CGI script or SSI file across all of your site’s pages, one lone line of code takes care of all your rounding needs across dozen, hundreds or thousands of pages.

Sure, some browsers will understand zilch to the code but, hey, browsers have gotten very accustomed to ignoring JavaScript errors and, ironically, deal with them a lot better than CSS or XHTML markup. Also, provided the code is well written, errors will be limited to antique browsers that wouldn’t be supported by the pure-CSS methods anyway. As far as “bloat” goes, I agree reading a JavaScript file takes time but caching will alleviate that concern when a user browses an entire domain. And think of how many robots would load your extra CSS code while ignoring the JavaScript include…

In comparison, using background images and nested divs results in less actual markup at rendering time but, since you need to add three or four divs within each div you want to round, more style-related markup in every page. Worse, you cannot simply zap the single line within the JavaScript include file (however you make it work) to revert to a clean CSS2 layout, that you can then update with a CSS3 stylesheet when the time has come.

After all, I’m only FJ so I’m sure I’m missing something big. I know many of you are experts on web design matters. Would you care to enlighten me?