Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Funny, I <em>just</em> had and solved this problem yesterday!</p> <p>The issue is that even though you specify the XHTML doctype, the DOM (at least in FireFox) will only follow XHTML rules if the Content-Type header is set appropriately, like <code>application/xhtml+xml</code>. This includes manipulating the DOM with JavaScript, including jQuery. As an experiment, consider the following code:</p> <pre><code>var foo = $('&lt;div&gt;&lt;/div&gt;'); foo.html('&lt;img src="#" /&gt;'); console.debug(foo.html()); </code></pre> <p>This code will have different results depending on what Content-Type is set. If the Content-Type is <code>text/html</code>, you'll get back <code>&lt;img src="#"&gt;</code>, because with plain-ole HTML, that is correct. However, if the Content-Type is <code>application/xhtml+xml</code>, or any of the other acceptable MIME content types for XHTML, you should get back <code>&lt;img src="#" /&gt;</code>.</p> <p>So, whatever server-side framework you're using, you'll need to add that header to the response. If it's a static file, you should be able to do it with a meta tag:</p> <pre><code>&lt;meta http-equiv="Content-Type" content="application/xhtml+xml" /&gt; </code></pre> <p>You can check the headers for the page load using the NET tab in <a href="http://getfirebug.com/" rel="nofollow noreferrer">FireBug</a>.</p> <p>I had the additional issue with ASP.NET MVC where it wouldn't set content type, even though I was specifically setting it. The trick is that you need to set it <em>after</em> the call to view. So, this should work:</p> <pre><code>public void ActionResult Index() { var result = this.View(); this.Response.ContentType = "application/xhtml+xml"; return result; } </code></pre> <p><strong>EDIT:</strong> I just saw your edit and you're setting the wrong <code>Content-Type</code> with your meta tag. See the rest of my answer for more details.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload