Connecting Tech Pros Worldwide Forums | Help | Site Map

Cannot set background color (XML+CSS)

michael_quinlivan@hotmail.com
Guest
 
Posts: n/a
#1: Jul 24 '05
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:
www.houseofnerds.com/mathml_test.xml

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??


Bart
Guest
 
Posts: n/a
#2: Jul 24 '05

re: Cannot set background color (XML+CSS)


Op 6 Jul 2005 00:16:40 -0700 schreef michael_quinlivan@hotmail.com:
[color=blue]
>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:
>www.houseofnerds.com/mathml_test.xml
>
>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??[/color]

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

First of all, your page throws multiple errors when validating
(http://validator.w3.org/check?uri=ht...thml_test.xml),
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
--
Bart Broersma
broersma.juda_ANTISPAM_@tiscali.nl
(ff _ANTISPAM_ wegpoetsen uit dit adres natuurlijk)
michael_quinlivan@hotmail.com
Guest
 
Posts: n/a
#3: Jul 24 '05

re: Cannot set background color (XML+CSS)



[color=blue]
> I've no experience in xml/xhtml/xls but:[/color]

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
[color=blue]
>
> First of all, your page throws multiple errors when validating
> (http://validator.w3.org/check?uri=ht...thml_test.xml),
> maybe you should solve these first.[/color]

....would not know how to solve this. I ripped off the code from
another site.
[color=blue]
> Second: put a border around the body, this will show you that the main
> content is outside the body.[/color]

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 :)
[color=blue]
> If you remove the xml stylesheet (I can't see what it does anyway),[/color]

Neither do I, but if I remove it, IE breaks...
[color=blue]
> You might consider applying a background to html instead:
> html{ background-color: #c8ffc8;}[/color]

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
MQ

Closed Thread