Closed Bug 263674 Opened 20 years ago Closed 20 years ago

Renderer problems with combination of italics <em> and lists <li>

Categories

(Core :: DOM: HTML Parser, defect)

x86
Windows XP
defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 181697

People

(Reporter: metlin, Unassigned)

References

()

Details

Attachments

(1 file, 2 obsolete files)

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; rv:1.7.3) Gecko/20040913 Firefox/0.10
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; rv:1.7.3) Gecko/20040913 Firefox/0.10

I had noticed this first on Slashdot, and submitted it as a bug-report to
Slashcode. But it seems that the problem is specific to the Moz. renderer only.

Consider the following --

--- begin ---

Foo bar

<em>
<li>Something
<li>Something more
</em>

This should not be italic.

--- end ---

Ideally, the sentence, "This should not be italic" should not be italic since
I've closed the <em/> tag. However, it is.

You can see it at work here -
http://slashdot.org/comments.pl?sid=124847&cid=10481209

For some odd reason, the combination of <em> and <li> makes the <em> tag stay
persistent.

I guess the problem is because that code is not exactly sticking to valid HTML.
HTML 3.2 spec gives you the freedom to NOT close the <li> tags, however it also
necessiates the presence of the opening and closing [<UL>] tags. I guess the
only reason I noticed this is because Slashdot allows you to post <li> without
the <ul> elements.

That could be what is making the renderer get confused. 

Reproducible: Always
Steps to Reproduce:
1. Specify the HTML code given in the details
2. View the code on the Moz. broswers mentioned in the report


Actual Results:  
The sentence outside the realm of the <em> italics tag should not be in italics,
but it is.

Expected Results:  
The sentence, "This should not be italic" should not have been in italics. 

I also noticed that the same problem occurs in Mozilla 1.7.3 - I'd tried viewing
the page in Mozilla 1.7.3 as well as MSIE 6.0, and only the former (apart from
Firefox) seems to be having the problem.
Attached file testcase (obsolete) —
I see the problem on /.
But the attached testcase works fine
Its a /. bug
[code]
<em> 
 <li>Something<br></li>
 <li>Something more
<br><br><br>
Is this still Italic? Yup it is.<br><br>Strange, the following code causes
Slashcode to get foobared-
<blockquote>
<tt>&lt;em&gt;&lt;li&gt;Something<br>&lt;li&gt;Somethin<nobr>g<wbr></nobr>  
more<br>&lt;/em&gt;</tt> </blockquote>
</li></em></td>

Neither them </em> not the </li> tags are in the right place
Status: UNCONFIRMED → RESOLVED
Closed: 20 years ago
Resolution: --- → INVALID
Oops, made wrong testcase
indeed, text after </em> stays in italic
Status: RESOLVED → UNCONFIRMED
Resolution: INVALID → ---
Attached file the right attachement (obsolete) —
this one showing the problem
Attachment #161609 - Attachment is obsolete: true
The example you've given does not show the code outside the <em> tag -- this
code demonstrates the bug rightly.
Did dig a bit deeper

What is wrong is that the <UL> or <OL> opening and closing tags are missing

http://www.w3.org/TR/REC-html40/struct/lists.html#h-10.2

Add them before and after the list and it works fine
Attachment #161613 - Attachment is obsolete: true
This is invalid, in my opinion, too. Gecko can't guess where list item ends.
Since there is no </li> and no </ul> it assumes that the list ends at EOF, thus
your code:
----
<body>
<em><li>foo<li>bar</em>
<br><br>something
</body>
----
is equivalent to this:
----
<body>
<em>
 <ul>
  <li>foo</li>
  <li>bar <!-- ignored /em - no em tag can be closed here>
      <br><br>
      something
  </li>
 </ul>
</em>
</body>
----

As Peter said in coment 6, you should either close <li>s or put them inside an
<ul></ul>. Then it works fine:
----
<html>
<body>
<em>
<ul>
<li>foo
<li>bar
</ul>
</em>
<br><br>
something
</body>
</html>
Yup. If you notice, I'd mentioned that in my original submission -- 

"I guess the problem is because that code is not exactly sticking to valid HTML.
HTML 3.2 spec gives you the freedom to NOT close the <li> tags, however it also
necessiates the presence of the opening and closing [<UL>] tags. I guess the
only reason I noticed this is because Slashdot allows you to post <li> without
the <ul> elements."


(In reply to comment #6)
> Did dig a bit deeper
> 
> What is wrong is that the <UL> or <OL> opening and closing tags are missing
> 
> http://www.w3.org/TR/REC-html40/struct/lists.html#h-10.2
> 
> Add them before and after the list and it works fine
probably related to bug 181697. My personal opinion is that this is invalid.
Component: Web Site → HTML: Parser
Product: Firefox → Browser
Version: unspecified → Trunk
Assignee: bugs → parser
This is actually a dupe of bug 181697. <strong> and <em> are both phrasal level
elements (and thus this is really the same bug). I'm marking this as a DUPE.

*** This bug has been marked as a duplicate of 181697 ***
Status: UNCONFIRMED → RESOLVED
Closed: 20 years ago20 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: