Archive for February, 2009

A class of its own

Friday, February 13th, 2009

Roger Johansson, author of the excellent 456 Berea Street blog, wrote a post about how classes in HTML and CSS are frequently called “CSS Classes“. I thought I’d reply, but Roger has the blog commenting turned off nowadays, so I do it here instead.

I think it’s really good that Roger points out that the class=”" attribute is not all about CSS. Using CSS classes is really convenient in Javascript, both to indicate elements that should be processed and to show states. It can even be used to carry data used by scripts. At least until we start using the data-* attribute in HTML 5.

But HTML/CSS classes is stillsomething wholly different from the classes used in many programming languages, inlcuding Javascript where it is a reserved keyword (Yet another reason why we see property/variable names like cssClass).

in the world of XML/HTML/CSS/JS/JSON, I think I prefer class attribute.

getComputedStyle() properties in Webkit

Friday, February 6th, 2009

The getComputedStyle() method is used when you want to get the style information of an HTML element. If you use the style property, you only get the inline style, but getComputedStyle() gives you what is set in the stylesheets. IE has an almost-similar property called currentStyle, and although they don’t work the same way they mostly give you cross-browser functionality.

In Safari and Chrome, getComputedStyle() has properties for each of the CSS props that getComputedStyle() in Webkit can extract. This makes it easy to loop these and seeĀ  these properties, which is useful since some of the CSS 2.1 stuff that Webkit supports in CSS is missing, like “content”. (This is reported as a bug in Webkit. Thanks to Mark Rowe for pointing this out).

The list contains some 50 “-webkit-” vendor specific properties and some SVG stuff.

The whole list is available at this page.