Closed
Bug 183875
Opened 22 years ago
Closed 22 years ago
css style for <a> tag apply to following text even if the tag is empty (ends in />)
Categories
(Core :: Layout, defect)
Tracking
()
RESOLVED
INVALID
People
(Reporter: Eugen.Dedu, Unassigned)
Details
Attachments
(1 file)
575 bytes,
text/xml
|
Details |
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2) Gecko/20021204 Debian/1.2.1-1
Build Identifier: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2) Gecko/20021204 Debian/1.2.1-1
In this example, the tag <a id="buts" name="buts"/> is an empty tag ending in />.
As defined in the CSS, the style "background-color: silver" should be applied to
the empty <a> tag, and only to it.
However, it is applied to the following text (This is the line etc.) too (i.e.
the bkg color become silver if you put your mouse on the text). This is wrong.
This text should not change bkg.
Note: replacing <a id="buts" name="buts"/> with <a id="buts" name="buts"></a>
solves the problem.
Maybe I am wrong?
Reproducible: Always
Steps to Reproduce:
Here is the example:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> <!--xml:lang="en" lang="en"-->
<head>
<title>Bug testcase</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<STYLE TYPE="text/css">
a:hover {
background-color: silver
}
</STYLE>
</head>
<body>
<a id="buts" name="buts"/>This is the line without end tag.<br>
Is this a bug?<br>
If so, it would be nice to fix it...<br>
</body>
</html>
Comment 1•22 years ago
|
||
The same issue was mentioned in bug 1608222, but the cause was that it was
partially an XHTML document, partiall HTML. Is this the case in your tests ?You
do have the correct DOCTYPE, but there's also the MIME-type.
BTW : isn't it <a id="buts" name="buts" /> ? (space before the />).
Reporter | ||
Comment 2•22 years ago
|
||
Sorry, there were a few errors in the code. Now it passes the W3C validator,
but the error still exists.
Comment 3•22 years ago
|
||
We don't support XML empty-tag syntax for text/html, except to the extent
we don't break on normally empty tags like <br/>. INVALID. Serve your
document as text/xml, application/xml, or application/xhtml+xml if you want
to do this.
Status: UNCONFIRMED → RESOLVED
Closed: 22 years ago
Resolution: --- → INVALID
Updated•22 years ago
|
Attachment #108476 -
Attachment filename: a.html → a.xhtml
Attachment #108476 -
Attachment mime type: text/html → application/xhtml+xml
Comment 4•22 years ago
|
||
Eugen, I edited your attachment 108467 [details], changing the mimetype. Now it displays
properly.
I wonder, though: if we receive a document as mime type text/html, but it
contains the XHTML DTD, why don't we parse it as XHTML instead?
Comment 5•22 years ago
|
||
Because if we did, we would have to fail fatally on well-formedness errors. Try
running the "xhtml as text/html" out there through a validator, and you will see
why this is a problem (hint: almost none of it is well-formed)
Updated•22 years ago
|
Attachment #108476 -
Attachment mime type: application/xhtml+xml → text/xml
Comment 6•22 years ago
|
||
Private email from Eugen:
> But : how can I tell to the browser the mimetype ?
You have to configure your webserver. Apache and IIS both have configuration
tools that let you map file extensions to mimetypes.
> - I changed the name of the file from a.html to a.xml and now it works.
> Is this what I should do? I fear that other browsers do not print it
> properly in this case...
This is a more difficult problem. If you serve it as application/xhtml+xml, IE
will prompt you to download the file. If you serve it as text/xml, IE will
display the file as color-coded XML. Either works in mozilla, but if you serve
as text/html, you get the problem described here.
Question (for bzbarsky, perhaps): in this situation served as text/html, could
we allow XML-style empty tags but still do loose parsing? How much code would
need to be changed (in the parser, presumably)?
Comment 7•22 years ago
|
||
> could we allow XML-style empty tags but still do loose parsing?
We used to. It caused horrible problems on many many sites.
Reporter | ||
Comment 8•22 years ago
|
||
For comment #6:
> > But : how can I tell to the browser the mimetype ?
>
> You have to configure your webserver. Apache and IIS both have configuration
> tools that let you map file extensions to mimetypes.
This does not work when the site is on a public provider (e.g. geocities).
You need to log in
before you can comment on or make changes to this bug.
Description
•