Closed Bug 431878 Opened 16 years ago Closed 16 years ago

<LINK> should never load when emebedded into the <BODY> element.

Categories

(Core :: DOM: HTML Parser, defect)

x86
Windows XP
defect
Not set
normal

Tracking

()

RESOLVED INVALID

People

(Reporter: fremycompany, Unassigned)

Details

Attachments

(3 files)

User-Agent:       Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 3.0.04506.30; InfoPath.1; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022)
Build Identifier: 2.0.1.14

<html>
    <body>
        <!-- Should be ignored -->
        <link 
          rel="stylesheet"
          href="data:text/css,html{color: red}"
        />
        <!-- Content of the document -->
        <div>This should be black.</div>
     </body>
</html>

Reproducible: Always

Steps to Reproduce:
1. Create an HTML page with a LINK in the BODY
2. Run the page
3. See that the LINK were applied
Actual Results:  
The LINK is applied as it was in the HEAD section, which is not true.
In fact, the LINK is moved to the HEAD section (you can see through the DOM).

The LINK tag should not move and should be ignored.

Expected Results:  
"Unlike A, it [[ the LINK tag ]] may only appear in the HEAD section of a document." (HTM4)


"Where this tag [[LINK]] may be used :
- Where metadata content is expected. [[And thus not in the BODY]]
- In a noscript element that is a child of a head element. " (html5)

==> Both specify that LINK can't be in the BODY tag, and should thus be ignored (as the BASE tag is when putted in the BODY tag)

http://www.w3.org/TR/html4/struct/links.html#h-12.3
http://www.w3.org/TR/html5/#base
Creating independent test case in HTML 4.01, and XHTML 1.0.
Attached file HTML 4.01 testcase
Here is the HTML 4.01 Test Case for this bug.
Attached file XHTML 1.0 testcase
HTML 1.0 DOCTYPE testcase
Attached file No DOCTYPE testcase
This testcase has no DOCTYPE.
All of these test cases show the text as red in Firefox 3.0 on XP, and in Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.1a1pre) Gecko/2008071703 Minefield/3.1a1pre on Vista. However, they show as black (correct) in IE7 and IE8 B1, so it is a FF issue.
Don't stop reading specs as soon as you find something you like.

From the HTML5 draft cited in comment 0:

8.2
(...)
For HTML documents, user agents must use the parsing rules described in this section to generate the DOM trees. Together, these rules define what is referred to as the HTML parser.
(...)
This specification defines the parsing rules for HTML documents, whether they are syntactically correct or not. 
(...)

8.2.5.10. The "in body" insertion mode
(...)
A start tag token whose tag name is one of: "base", "command", "eventsource", "link", "meta", "noframes", "script", "style", "title"

    Process the token using the rules for the "in head" insertion mode.

In summary, moving the element to the head is the correct behavior.
Status: UNCONFIRMED → RESOLVED
Closed: 16 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: