Bug 22539

Summary: An empty <a> element inside an HTML document taints the following elements' CSS type information
Product: WebKit Reporter: Alexander Mitin <Alexander.Mitin>
Component: DOMAssignee: Nobody <webkit-unassigned>
Status: RESOLVED CONFIGURATION CHANGED    
Severity: Normal CC: ahmad.saleem792, ap, bfulgham, jchaffraix, rniwa, simon.fraser, zalan
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
See Also: https://bugs.webkit.org/show_bug.cgi?id=61697
Attachments:
Description Flags
Reduction (based on Alexander Mitin's example) none

Description Alexander Mitin 2008-11-28 00:28:02 PST
I beleive I've found a bug while rendering the xhtml transitional document by WebKit nightly (28.11.2008), Safari 3.2.1 and the latest Chrome affected as well.
Here is the simple test case:

test.html:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head> 
    <title>test</title> 
    <link rel="stylesheet" href="default.css" type="text/css" />
</head> 
<body> 
<table border="1"> 
    <tr><td> <a name="top" /> 
    <table> 
        <tr><td> <a name="23" /> 
        <table border="1"> 
            <tr>
                <td>text1</td>
                <td>text2</td>
            </tr> 
            <tr><td colspan="2"><a href="#top">top</a></td></tr>
        </table> 
        </td></tr> 
        <tr><td> <a name="12" /> 
        <table border="1"> 
            <tr>
                <td>text3</td>
                <td>text4</td>
            </tr> 
            <tr><td colspan="2"><a href="#top">top</a></td></tr>
        </table> 
        </td></tr> 
    </table>
    </td></tr> 
</table>
</body> 
</html> 

default.css:
a:link, a:active, a:visited
{ 
	color: #006699;
	text-decoration:none;
}
a:hover
{
	text-decoration:none;
	color: #EE4000;
}

The document passes the validation by w3c online at http://validator.w3.org/

Actual behaviour:
Text in table cells change its color by mouse hovering on it as if it surrounded by <a> tag.
Expected behaviour:
Text in table cells stay black.
Comment 1 Julien Chaffraix 2009-02-08 06:36:22 PST
While trying to reproduce the bug, I noticed something with your test case. I made the mistake of serving it with a Content-Type of text/html and I could definitely reproduce the bug.
However if I served it with a Content-Type of application/xhtml+xml, the behaviour is correct.

Could you confirm that you fell into the same pitfall so that we can update the bug and reduce the test case a bit more?
Comment 2 Alexander Mitin 2009-02-09 10:37:19 PST
When I saw this behavior the Content-Type was set to 'text/html'. Sorry, can't test it using the Content-Type set to 'application/xhtml+xml' but I believe that it would work as expected. And one more thing: when I created the test case I loaded it into browser directly using file: proto (not using http-server) and the error persisted. 
Comment 3 Julien Chaffraix 2009-02-11 21:38:30 PST
Thanks for your reply. I have tweaked the bug information with your comment and to reflect my research on this.

FYI the Inspector suggests strongly an HTML DOM bug as the empty <a> tags seem to contain other elements.
Comment 4 Julien Chaffraix 2009-02-11 21:41:42 PST
Created attachment 27586 [details]
Reduction (based on Alexander Mitin's example)
Comment 5 Ahmad Saleem 2022-07-27 09:36:04 PDT
I am not able to get expected result from the reduction attached test case in Safari 15.6 on macOS 12.5 and text in table cell change color based on text-decoration. It is same in Chrome Canary 106.

Although for some reason, Firefox is extending text-decoration to table borders as well and changing table border color accordingly.

Is it web-spec clarity issue or is Firefox is doing right? I am not sure but just wanted to share latest results. Thanks!
Comment 6 Alexander Mitin 2022-07-27 10:39:30 PDT
Wow, it's almost 14 years passed since I reported this bug so I just forgot about it. :)

Probably, the WebKit code base has been significantly changed since then, and this issue has been fixed by itself or someone silently or accidentally fixed it.

Sorry, no any idea about Firefox.
Comment 7 Ryosuke Niwa 2022-07-27 14:48:03 PDT
Self closing anchor tag isn't really a thing in HTML as you can see in Web Inspector. All browsers match in their behaviors. -> Config Changed