<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Mar 17, 2019, at 8:48 PM, Nathan Phillip Brink &lt;<a href="mailto:ohnobinki@ohnopublishing.net" class="">ohnobinki@ohnopublishing.net</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="">Hi Karl,<br class=""><br class="">On Sun, Mar 17, 2019 at 07:47:22PM -0400, Karl Kleinpaste wrote:<br class=""><blockquote type="cite" class="">On 3/17/19 2:44 PM, Nathan Phillip Brink wrote:<br class=""><blockquote type="cite" class="">It sounds like you’re trying to render XHTML using an HTML parser.<br class=""></blockquote>If there is a way to make WebKit /*not*/ operate in an XHTML mode, I'm<br class="">not aware of it.<br class=""></blockquote><br class="">Sorry, I may be going a bit off-topic by pursuing this.<br class=""><br class="">I am quite sure you are running WebKit in HTML mode and not XHTML<br class="">mode.<br class=""><br class="">I don’t have an easy way to directly test WebKit per se. But I can<br class="">demonstrate what I am describing and have tested it with Midori-0.5.11<br class="">which claims to be WebKit. The following also works in any modern<br class="">browser (IE, Edge, Firefox, Chrome, or Mobile Safari to name a few).<br class=""><br class="">I have defined CSS rules which set anything with a class of div2 to be<br class="">green and used it for both of the following files. In each file, I<br class="">have text, an empty div div1, more text, an empty div div2, and more<br class="">text. Each empty div uses the self-closing syntax “&lt;div/&gt;”:<br class=""><br class="">HTML: <a href="http://cdn.ohnopub.net/cdn/binki/sword-devel/xhtml-vs-html/index.html" class="">http://cdn.ohnopub.net/cdn/binki/sword-devel/xhtml-vs-html/index.html</a><br class=""><br class="">XHTML/XML: <a href="http://cdn.ohnopub.net/cdn/binki/sword-devel/xhtml-vs-html/index.xhtml" class="">http://cdn.ohnopub.net/cdn/binki/sword-devel/xhtml-vs-html/index.xhtml</a><br class=""></div></div></blockquote><div><br class=""></div>I noticed that not only did you have the xml pre-processor as the first line</div><div>&lt;?xml version="1.0”?&gt;</div><div>But you also had the namespace declaration for xhtml.</div><div>&lt;html xmlns="<a href="http://www.w3.org/1999/xhtml" class="">http://www.w3.org/1999/xhtml</a>”&gt;</div><div><br class=""></div><div>Is the later necessary to put the parser into XML mode?</div><div><br class=""></div><div>Are either really needed if you are delivering it with a Content-Type:text/xhtml?</div><div><br class=""></div><div>In Him,</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>DM</div><div><br class=""><blockquote type="cite" class=""><div class=""><div class=""><br class="">If you visit the first link, then WebKit is reading the markup using<br class="">an HTML parser. This causes the behavior you describe of self-closed<br class="">“&lt;div/&gt;” tags being treated as equivalent to opening “&lt;div&gt;”<br class="">tag. The resulting document tree has the trailing text inside div2,<br class="">making it green. If you visit the second link, then WebKit is reading<br class="">the markup in XHTML (XML) mode because Content-Type is set. This<br class="">causes it to parse it as an XML document and then render the resulting<br class="">DOM as a second step. The resulting document tree has the trailing<br class="">text after div2 as a direct descendent of body. Thus the text is not<br class="">part of div2 and does not become green.<br class=""><br class="">The HTML parser is special and you are seeing the effects of using an<br class="">HTML parser to parse XHTML instead of using an XML or XHTML parser to<br class="">parse XHTML.<br class=""><br class="">HTML does not have a self-closing tag syntax. For elements which would<br class="">normally be self-closed in XML/XHTML such as br and link, it relies<br class="">instead on a list of void elements which the parser itself knows<br class="">about: <a href="https://www.w3.org/TR/html/syntax.html#void-elements" class="">https://www.w3.org/TR/html/syntax.html#void-elements</a> . Whenever<br class="">it encounters one of these elements, it immediately closes it out in<br class="">the document tree and doesn’t give it any children.<br class=""><br class="">The HTML parser is required to basically ignore the forward-slash in<br class="">“&lt;div/&gt;” or “&lt;br/&gt;”. This was intended to allow websites to slowly<br class="">transition to XHTML if proper care was taken. The result is that<br class="">“&lt;div/&gt;” will be treated the same as “&lt;div&gt;” when using an HTML<br class="">parser to parse the file. See rule 6 regarding SOLIDUS at<br class=""><a href="https://www.w3.org/TR/html/syntax.html#start-tags" class="">https://www.w3.org/TR/html/syntax.html#start-tags</a> and 0x2F under step<br class="">4 at <a href="https://www.w3.org/TR/html/syntax.html#get-an-attribute" class="">https://www.w3.org/TR/html/syntax.html#get-an-attribute</a> .<br class=""><br class="">If you want to get the expected results, you should either process the<br class="">XHTML into HTML before feeding it to WebKit or set WebKit to parse the<br class="">file as XHTML instead of HTML.<br class=""><br class="">-- <br class="">binki<br class=""><br class="">Don’t forget to check for missing or extraneous apostrophes!<br class="">_______________________________________________<br class="">sword-devel mailing list: <a href="mailto:sword-devel@crosswire.org" class="">sword-devel@crosswire.org</a><br class=""><a href="http://www.crosswire.org/mailman/listinfo/sword-devel" class="">http://www.crosswire.org/mailman/listinfo/sword-devel</a><br class="">Instructions to unsubscribe/change your settings at above page</div></div></blockquote></div><br class=""></body></html>