Phillip Pearson - web + electronics notes

tech notes and web hackery from a new zealander who was vaguely useful on the web back in 2002 (see: python community server, the blogging ecosystem, the new zealand coffee review, the internet topic exchange).


Microformats and (not) unsetting CSS styles

Hmm, looks like you can't unset CSS styles. Damn. This causes trouble for microformats, as it results in issues like hReview description areas being invisible in Wordpress with the default style.

I guess the solution is for blogging tools and aggregators to not use CSS classes like 'description' and 'item' (Bloglines has this problem - it makes my reviews look weird). That doesn't help much right now though. I'm thinking of putting a hack into the Structured Blogging plugin that rewrites <div class="description"> to <div class="description" style="font-size: 1em; text-align: left; color: black">, but then that would cause trouble for people not using Kubrick. Grr...

I imagine it's possible to delete CSS rules with Javascript hackery. Hmm...

Update: I bring you: an ugly (Wordpress-specific) hack to let you give something a CSS 'description' class without making it obey the CSS 'description' rules! Here we go:

<script language="javascript">
    divs = document.getElementsByTagName('div');
    if (document.all) className = 'className'; else className = 'class';
    for (i = 0; i < divs.length; i += 1) {
        element = divs[i];
        if (element.getAttribute(className) == 'description'
            && !(element.parentNode.nodeName == 'DIV'
                 && element.parentNode.getAttribute('id') == 'headerimg'))
            element.setAttribute(className, '');

Update: The Wordpress bug report raised by ryansking (see second link from the top of this post) has been closed as 'wontfix', with a suggestion to add a CSS rule like .hreview .description { color: inherit; }. This fixes the problem in Firefox, but not in IE... so I guess the Javascript has to stay. This is fine for SB users, but it basically means that if you want to use hReview on Wordpress, you either need to install the SB plugin or edit your templates.

... more like this: [] ... topic exchange: [, , ]