2

Is there any way to disable one CSS property value only? For example, with the property 'text-decoration' there are possible values of none, underline, overline, line-through, blink and inherit.

I would like to allow all values of text-decoration with the exception of underline on ALL elements.

The pages I'm working with are dynamically generated, and can have content from all over the web- so it's not possible to target any specific element. Using text decoration 'none' works of course, but it blows away all other values as well :(

Suggestions?

Nicros
  • 5,031
  • 12
  • 57
  • 101

2 Answers2

2

There's no way to do this with just CSS and HTML. What you'd need is something like a property selector to target all of the elements on your page with text-decoration set to underline, but such a thing doesn't exist right now.

However, if JavaScript is an option, then you could accomplish this. You would first determine the style of the elements and then, if you needed to, set the style to get rid of the underline.

Community
  • 1
  • 1
jamesplease
  • 12,547
  • 6
  • 47
  • 73
2

Since there's no such thing as property selectors in Javascript and neither JQuery, You should get all of possible elements and then check for their css property and change it if needed. Something like this: $('*').each(function() { if ($(this).css('PROPERTY') == 'FORBIDDEN-VALUE') { $(this).css('PROPERTY', 'REPLACE-VALUE'); } });

Hosein
  • 581
  • 1
  • 7
  • 29
  • Thanks for the code chunk! I will play with this. I wonder what the performance impact of this would be... – Nicros Jan 07 '13 at 19:00
  • It depends on the number of elements you're dealing with in your document. Maybe in your case you can add some code to your JQuery selector to filter them down. That would highly increase the performance. – Hosein Jan 07 '13 at 19:12
  • Good idea... I'll investigate. Cheers! – Nicros Jan 07 '13 at 22:06