Image button found guilty of not being valid xhtml horror!!!

The .net image button seems so innocent but a trip over to and the html validator soon exposes the terrible truth. Prepare yourself for this, sit down, have a large brandy ready… It renders border=”0″ even though you haven’t put one in there yourself! try it! Put any xhtml 1.0 transitional site into the validator:

And watch in utter horror while your site is rejected as a bad example to kids everywhere.

So what is going on here? And is there anyway out?

Well after some digging I found an excellent article:

It turns out the validator is unrecognised as a browser type to and so is presented with html 4.0 instead of xhtml, hence the border=”0″ debarkle.

Is there a workaround? Yes there is either don’t use image buttons or put this in your web.config:

case match=W3C_Validator*>
TagWriter = System.Web.UI.HtmlTextWriter
W3CDomVersion = 1.0

A solution to a weird problem, but necessary if like me you want that green tick 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.