Today, I got around to trying to tackle some of the XHTML validation errors we've been receiving on our sites at work.  One of the peskiest errors was what appeared to be a simple unclosed <img> tag–easy to fix, right?  Well, I promptly navigated to the xslt file, opened it up, and quickly found the offending tag. 

…it was already closed.


Honestly, I couldn't figure out what was going on.  Just to make sure, I recopied the most recent, seemingly correct version. 

No change. 

I went back to the file, made ABSOLUTELY sure that the tag was closed and that there were no weird quotes floating around.

No change.

By now, I was desperate.  I even started commenting out random bits of code around the <img> tag until I was POSITIVE that nothing else was causing this issue.

No change.


Well, it turns out the fix is pretty easy, and it all has to do with the "method" attribute of the <xsl:output> directive.  On my xslt file (which I did not create, BTW), the method was set to "HTML" like so:

<xsl:output method="HTML" …./>

For whatever reason, this method of output can do funky things like remove the self-closing parts of tags.  Dumb.

Anyway, I simply switched the More >