Search code examples
csssafaricss-content

Can't get css property of 'content' in Safari 4


I'm having the hardest time figuring out why Firefox3.1 returns the value of 'content' on a test element, while Safari 4 won't.

My sample page is setup like:

<style>
#asd{
content: 'test';
}
</style>

<div id="asd">
Bleh
</div>

And my JS is using getComputedStyle. This works for other properties like "background-color" but not for "content":

if( window.getComputedStyle ){
    var thestyle = window.getComputedStyle( document.getElementById('asd'), '');
    alert( thestyle.getPropertyValue('content') );
}

Is Safari more restrictive about the pseudo-element selectors, :before and :after? I tested with :after and that also fails, while FF succeeds in returning the data.


Solution

  • Safari only supports the content property on the :before and :after pseudo-elements.