<div style="font-style: italic">Applying the theorem, we see a magic result \(\rm x = 42\).</div>
<div style="font-style: italic">Applying the theorem, we see a magic result \(\mathrm{x = 42}\).</div>
It doesn't inherit it. Italics are used automatically for variable
names, so the "x" would be in italics no matter what the surrounding
CSS settings. Similarly the 42 will be in non-italics no matter what
the surrounding CSS.
If you are seeing such CSS effects, then THAT is a bug, and I would
appreciate a pointer to a page that shows that (and a report of the
browser and OS that you are using). The snippet you sent works for me
as expected (italic "x" and normal 42, regardless of the font-style in
the surrounding div).
>> <div style="font-style: italic">
>> Applying the theorem, we see a magic result \(\rm x = 42\).
>> </div>
>>
>> or
>>
>> <div style="font-style: italic">
>> Applying the theorem, we see a magic result \(\mathrm{x = 42}\).
>> </div>
>>
>> Currently there is no way to have this done automatically, so it
>> would
>> have to be inserted by hand.
>
> Yes, my current hack is to write a preprocess which inserts <span
> style="text-style=normal"> around every piece of math.
That should not affect the math in any way. (Also, you mean "text-
style: normal" with a colon and an equal.)
My examples show additional TeX commands that must be used as part of
the mathematics, not CSS control. As I mentioned in my response,
MathJax sets the font style itself on each character, depending on how
that character is used. Global CSS should not affect that, except in
very special cases that I won't go into here.
Davide