CSS Meta Data

Does anyone know if its somehow possible to store custom properties in CSS that can be fetched in Javascript.

CSS defines that any property, value or selector prefixed with a hyphen (-) is considered custom and is considered valid. It is only up to the browser to allow these declarations to be put into the document.

In IE, its possible to fetch any property (custom or not) from the element.currentStyle hash. I tried doing a similar approach by using the getComputedStyle method for all the other browsers, but I can’t seem to fetch the custom properties (other than the browser specific ones).


#container {
-custom-value:111;
}

Does anyone know if this is possible somehow across all browsers?

This belongs in the Javascript section and not hte CSS section. I’ll request it moved :).

Most browsers throw out any css rules they do not recognize- except for warnings in an error console,
if you have one, you’d never know they were there.

IE will parrot back whatever literal value it finds, which may help you in your problem,
but is usually just a pain, since ‘auto’ and ‘inherit’ and the like are often not the values you are looking for.

I’m not sure if it suits your needs, but you can access css rules programatically through document.styleSheets
http://www.javascriptkit.com/dhtmltutors/externalcss2.shtml