Closed
Bug 269185
Opened 20 years ago
Closed 20 years ago
Content types "text/xml", "application/xml" and "application/xhtml+xml" causes (minor) layout problems
Categories
(Core :: CSS Parsing and Computation, defect)
Tracking
()
RESOLVED
INVALID
People
(Reporter: zipdragon7, Assigned: dbaron)
References
Details
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; rv:1.7.3) Gecko/20041001 Firefox/0.10.1
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.3) Gecko/20040910
When using content type "text/xml", "application/xml" or "application/xhtml+xml"
will cause the following code not to display properly.
body {
background-color: black;
color: white;
}
or <body bgcolor="#000000">
or using inline style attributes (<body style="background-color: black;">)
but the weird thing is the elements other than "body" will work okay.
For example, inheritance:
<div style="background-color: inherit">
while you have "body {background-color: black; color: white;}" will actually
cause the <div> element to display a black background with white text.
The problem is, in fewer, less confusing words:
The background color of the document body will not change to any color, it will
remain white unless using the content type "text/html".
I tested this same document in Opera 7.54 Build 3869, and it supports the
display of the body's background color using the above content types.
Reproducible: Always
Steps to Reproduce:
1. Create a XHTML document using "text/xml", "application/xml" or
"application/xhtml+xml" as the content type.
2. Set the CSS "background-color" property to any color other than white for the
document's body (a.k.a. <body>).
3. Load document.
Actual Results:
The background color of choise is not shown at all.
Expected Results:
What ever makes it work using the content type "text/html" should be applied to
XHTML documents using the "text/xml", "application/xml" and
"application/xhtml+xml" content types.
Comment 1•20 years ago
|
||
BODY behaves like a DIV element in XHTML. Read <http://www.w3.org/TR/CSS21/colors.html#q2>: > This does not apply to XHTML documents.
Status: UNCONFIRMED → RESOLVED
Closed: 20 years ago
Resolution: --- → INVALID
*** Bug 269184 has been marked as a duplicate of this bug. ***
| Reporter | ||
Comment 3•20 years ago
|
||
(In reply to comment #1) > BODY behaves like a DIV element in XHTML. Read > <http://www.w3.org/TR/CSS21/colors.html#q2>: > > > This does not apply to XHTML documents. I read over the document you linked to, but I see nothing relevant to the issue. Perhaps if you could go into detail maybe then I'll understand better what you're trying to point out. I know <body> is like a block element, and it does apply to XHTML documents that use the content types listed. You're allowed to use "text/html" when using XHTML 1.0 for compatibility reasons because not all Web user agents are up to speed for handling XML-based documents. But anything aside from that you should really use "application/xhtml+xml" when serving XHTML documents. You should read http://www.w3.org/TR/xhtml-media-types/ instead. If anyone would like me to create a "before and after" example between using "text/html" and "application/xhtml+xml" using XHTML 1.0 Transitional and CSS, just ask.
Comment 4•20 years ago
|
||
If you use text/html XHTML will be treated as (invalid) HTML. The document you link to is non-normative W3C NOTE and doesn't say anything about *how* XHTML send as text/html must be treated. However, according to the W3C HTML WG, XHTML MUST be treated as HTML when send as text/html.
| Reporter | ||
Comment 5•20 years ago
|
||
(In reply to comment #4) > If you use text/html XHTML will be treated as (invalid) HTML. > > The document you link to is non-normative W3C NOTE and doesn't say anything > about *how* XHTML send as text/html must be treated. > > However, according to the W3C HTML WG, XHTML MUST be treated as HTML when send > as text/html. It says the document is "...not intended to be a normative specification. Instead, it documents a set of recommendations to maximize the interoperability of XHTML documents with regard to Internet media types." Which is what I already said before. Second, XHTML is not HTML, it's XML. So using "text/html" doesn't mean it's treated as invalid HTML. The Web user agent renders the document as if it were an HTML document because of the content type, if you used "application/xhtml+xml" then any XML-compatible Web user agent would use an XML parser to check for things like well-formedness. It keeps legacy Web user agents from getting confused by the XML document. For example, KDE's Konqueror. They boast about having good HTML 4.0 (never said 4.01) support with the exception of some minor details. http://konqueror.kde.org/features/browser.php So, for anyone who wanted to upgrade to XHTML 1.0, couldn't because of Web user agents like Konqueror that only support HTML 4.x. This is why you can send XHTML 1.0 documents using "text/html" and everything should work the same, because the elements are the same. Just as long as you don't use any XML processing instructions or use an XML declaration, your document should be rendered without error. The issue here is, when serving XHTML using "application/xhtml+xml" the CSS "background-color" property will not display properly.
Status: RESOLVED → UNCONFIRMED
Resolution: INVALID → ---
| Reporter | ||
Comment 6•20 years ago
|
||
I took the liberty of creating the example document, so that everyone can see what the problem is: http://dragontechsystems.com/draft/bugzilla.mozilla.org/index.xhtml In this example, you have four content types to choose from, "text/html" is chosen by default. You will notice a black background with two divisions with gray borders and white text (aside from hyperlinks). When you choose another content type other than "text/html" you will notice that the background color has turned white. I've also added two links to validate the document, one for markup and one for style just in case anyone thinks it's "bad HTML". I would like anyone who happens to read this, but does not experience this problem to leave a comment and the Mozilla product and version you are currently using. I have some new findings for this bug (or whatever it is). I have just tested this document using Mozilla 1.5 UA:[Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.5) Gecko/20031016] on my Linux PC. Using "text/html" and "application/xhtml+xml" BOTH display the black background, however the generic "text/xml" and "application/xml" do NOT display the background. I've never noticed this problem before because I often use Linux and try to stay away from Windows as much as possible, but unfortunately I have to use it when testing. Which is how I noticed the problem. Again, the test document is located at http://dragontechsystems.com/draft/bugzilla.mozilla.org/index.xhtml
Comment 7•20 years ago
|
||
# For HTML documents, however, we recommend that authors specify the background # for the BODY element rather than the HTML element. User agents should observe # the following precedence rules to fill in the background of the canvas of HTML # documents: if the value of the 'background' property for the HTML element is # different from 'transparent' then use it, else use the value of the 'background' # property for the BODY element. If the resulting value is 'transparent', the # rendering is undefined. This does not apply to XHTML documents. - http://www.w3.org/TR/CSS21/colors.html#q2 I assure you, as one of the people who _wrote_ that paragraph, that what it means is that if you send your document as text/html, body backgrounds will cover the entire canvas, but if you send it as application/xhtml+xml (or any other XML MIME type) that the body background will only cover the area that the body actually covers (it won't go outside its borders). There's no testcase in this bug. I need a testcase to tell you if it is valid or not. Based on the initial description in this bug, I'd say it was invalid.
| Reporter | ||
Comment 8•20 years ago
|
||
(In reply to comment #7) > # For HTML documents, however, we recommend that authors specify the background > # for the BODY element rather than the HTML element. User agents should observe > # the following precedence rules to fill in the background of the canvas of HTML > # documents: if the value of the 'background' property for the HTML element is > # different from 'transparent' then use it, else use the value of the 'background' > # property for the BODY element. If the resulting value is 'transparent', the > # rendering is undefined. This does not apply to XHTML documents. > - http://www.w3.org/TR/CSS21/colors.html#q2 > > I assure you, as one of the people who _wrote_ that paragraph, that what it > means is that if you send your document as text/html, body backgrounds will > cover the entire canvas, but if you send it as application/xhtml+xml (or any > other XML MIME type) that the body background will only cover the area that the > body actually covers (it won't go outside its borders). > > There's no testcase in this bug. I need a testcase to tell you if it is valid or > not. Based on the initial description in this bug, I'd say it was invalid. But, this talks about using the "background" property, not background-color although I guess they're similar. I created a document to show an example, and as I mentioned earlier it worked okay using Mozilla 1.5 (Linux)... well just "application/xhtml+xml". Also, when you define "body {background-color: black;}" the "entire background" should be black. I forgot to set the divisions to "inherit", so they will remain black to prove that the body's background is actually black. I just fixed that now. So, now the divisions inherit the black background, but the body still remains blank. If someone would go into more detail about whatever it is that I seemed to have missed, then maybe I'll understand if it's a software problem or a developer problem.
Comment 9•20 years ago
|
||
'background' is a shorthand property which, amongst other things, includes the 'background-color' property. Mozilla 1.5 almost certainly was buggy about this. We have since then fixed the bug to comply with the standards.
| Reporter | ||
Comment 10•20 years ago
|
||
(In reply to comment #9) > 'background' is a shorthand property which, amongst other things, includes > the 'background-color' property. > > Mozilla 1.5 almost certainly was buggy about this. We have since then fixed the > bug to comply with the standards. So, is everyone saying that the "background-color" property "should not" display when using XML documents or content types? Because that's what I'm hearing. It would help greatly if you could evaluate the test document and tell me if there's something I did wrong or overlooked when I stumbled upon this. Does my document's markup and style not follow standards?
Comment 11•20 years ago
|
||
Firefox 1.0 renders your test documents correctly. What you want to do is set the background on the _html_ element, not the body element. The body element has no height, so you can't see its background (put a border on it to see what I mean). The background-color will, and should, display, but only within the area of the element on which it is set. Since your <body> element is empty (it only contains two elements that are positioned and therefore do not contribute to its height), you can't see it. It works in HTML because of the bit in the CSS spec that I quoted above. Does that answer your question?
| Reporter | ||
Comment 12•20 years ago
|
||
(In reply to comment #11) > Firefox 1.0 renders your test documents correctly. > > What you want to do is set the background on the _html_ element, not the body > element. The body element has no height, so you can't see its background (put a > border on it to see what I mean). > > The background-color will, and should, display, but only within the area of the > element on which it is set. Since your <body> element is empty (it only contains > two elements that are positioned and therefore do not contribute to its height), > you can't see it. > > It works in HTML because of the bit in the CSS spec that I quoted above. > > Does that answer your question? Yeah, I'm also using 1.0... well 1.0 PR. Okay, so I should use: html { background-color: black; color: white; } for XHTML documents and: body { background-color: black; color: white; } for HTML documents. So, yes this answers my question. Well, I should ask one more thing. If I were to add text to the body of the document, then my styles would apply because there is actual content within the body, right? I tried your suggestion and it works perfectly and I couldn't be happier. :) So, is it safe to resolve the bug?
Comment 13•20 years ago
|
||
This is INVALID as stated before. Please don't reopen if you don't have a clue.
Status: UNCONFIRMED → RESOLVED
Closed: 20 years ago → 20 years ago
Resolution: --- → INVALID
| Reporter | ||
Comment 14•20 years ago
|
||
(In reply to comment #13) > This is INVALID as stated before. Please don't reopen if you don't have a clue. First, I didn't even know I reopened it because I overlooked the options of doing so. Second, I'm not a big fan of using bugzilla. I'm only using it because I thought there was an error in the software. And last, I've only had one other bug that I filed in the past so my experience in filing bugs is zero. Had your comments had been more detailed, not to mention helpful, then there wouldn't be a need to continue discussing this now irrelevant issue. You never made it clear that it was a "developer" issue, not a software issue, because if you had maybe I would "have a clue". So it was a mistake on my part, I can live with that. My hat's off to Ian for helping me, thank you ever so much. And I'm sorry for wasting everyone's time.
Comment 15•20 years ago
|
||
> Okay, so I should use: > html { > background-color: black; > color: white; > } > for XHTML documents and: > body { > background-color: black; > color: white; > } > for HTML documents. You can use the "html { }" rule for both HTML and XHTML if you want. > If I were to add text to the body of the document, then my styles would apply > because there is actual content within the body, right? Your background would be visible for that line of text, yes.
You need to log in
before you can comment on or make changes to this bug.
Description
•