Cannot set background color (XML+CSS)

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

Hi all,

I have noticed that the background color of an XML document cannot be
set properly using CSS (that is, you cannot define styles for the BODY
element of an XHTML document).

I have an example of this:

Because I am trying to display MathML embedded in the page, I need to
use XML, so I cannot convert this to HTML via XSLT.

The above page renders fine in IE (ignore the giberrish that appears if
you do not have a MathML display plug-in. The important thing is that
it displays the background color as green)  However, in Firefox (and I
assume Mozilla and Netscape), the background color is ignored, and it
is white??

Is there any way to acheive a different background color in both
browsers using XML + CSS??  Any other suggestions??

Re: Cannot set background color (XML+CSS)

Op 6 Jul 2005 00:16:40 -0700 schreef

Quoted text here. Click to load it

I've no experience in xml/xhtml/xls but:

First of all, your page throws multiple errors when validating
( ),
maybe you should solve these first.
Second: put a border around the body, this will show you that the main
content is outside the body.

If you remove the xml stylesheet (I can't see what it does anyway),
the css takes effect in FF: the line containing "MathML Test Page" has
a green background (this _is_ the body).
You might consider applying a background to html instead:
  html{ background-color: #c8ffc8;}

Hope this is of any use to you.

Bart Broersma
(ff _ANTISPAM_ wegpoetsen uit dit adres natuurlijk)

Re: Cannot set background color (XML+CSS)

Quoted text here. Click to load it

Hehe, neither do I, and if it wasn't for the MathML there is no way I
would have
put myself through the hell of trying to get this to work in XML

Quoted text here. Click to load it
( ),
Quoted text here. Click to load it

...would not know how to solve this.  I ripped off the code from
another site.

Quoted text here. Click to load it

it may render that way, but I still don't understand why.  After all,
the main content is clearly inside the body in the source file.  Let's
blame this on XML again :)

Quoted text here. Click to load it

Neither do I, but if I remove it, IE breaks...

Quoted text here. Click to load it

Thank u Bart, you have been a great help.  The above worked for me.
One day I will get around to figuring out XML and XSL, but I find it
irritating that
such a seemingly simple task I thought would take a couple of hours
would take three days :P

thanks again

Site Timeline