Forum How do I...?

how can I block inline styles?

oswald_i
hello,

In my HTML text I have some sections with inline styles (mainly: font-size, line-height and font color).
Can I edit my CSS so that Prince can skip those inline styles and only follow the styles in the CSS?

For example, if my CSS font-size for body text is 12pt and on a specific paragraph I have <p style="font-size:20pt">, I would need to keep font-size:12pt (not 20pt).

Thank you!
mikeday
If you can target that particular paragraph, you could apply "font-size: inherit !important" to override the style attribute. But you will need to know which paragraph, eg. with an ID or class attribute.

Alternatively, you could target every <p> element that has a style attribute, like this:
p[style] { font-size: inherit !important }
oswald_i
thank you very much.
Would this solution work also if the inline styles are added via a span tag? (instead of being added in the p tag)
mikeday
Yes, you could do something similar to override span or span[style].
ixgal
thank you!
And which selector should I use to skip the inline styles span in footnotes?
mikeday
What markup are you using for footnotes? Is it a span with a particular class?
ixgal
I am using class "footnote".
The problem is that when I apply:

p span { font-size: inherit !important } , this works ok in preventing inline styles for normal paragraphs, but it ends up changing the font-size of footnotes and applies the same font-size as in normal p
mikeday
You could say:
p span:not(.footnote) { ... }