Someone pointed out to me recently that my website doesn't validate. It seems the error is coming from the fact that the JSON returned for StackOverflow flair contains an invalid IMG tag in gravatarHtml:

<img src="..." height="50" width="50" alt="">

The IMG tag isn't self-closing. Should be:

<img src="..." height="50" width="50" alt=""/>
  • What an interesting dilemma... To XHTML or not XHTML, that is the question.
    – Josh Hunt
    Sep 15, 2009 at 7:54

2 Answers 2


We've deprecated the JSON and IFRAME flairs in favor of the simpler .png image flairs:


Can you switch to that?


Image tags should not be closed in valid HTML, which Stack Overflow is

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd" >

Closing tags are reserved for XHTML. It's kind of a difficult move from here, since both parties can't be satisfied from the same source.

  • Wouldn't the <img /> style also work on Stack Overflow? Aug 18, 2009 at 1:51
  • 3
    So why not offer up only the Gravatar URL? I don't see a reason to send the HTML along at all. Aug 18, 2009 at 1:56
  • 1
    Closing image tags in HTML is invalid as well. You can't support XHTML while serving HTML and vise versa. Aug 18, 2009 at 1:57
  • If all you want is the gravatar URL then you'll have to parse the response yourself, several pieces of code on META do exactly that. What you suggested isn't a bug though, it's a feature request. Aug 18, 2009 at 1:59
  • 1
    At the time of posting, I believed it was a bug. Furthermore, it just seems a little silly that I have to parse the URL from a piece of HTML that's just going to get inserted into HTML/XHTML again anyway. Aug 18, 2009 at 2:20
  • I'm not sure I understand your argument anymore Aug 18, 2009 at 2:25
  • 3
    What is there to misunderstand? Wouldn't it just be easier to send the Gravatar URL itself in the JSON response rather than an HTML tag? Aug 18, 2009 at 2:37
  • Well I think it's clearly easier to send the HTML tag, but more proper to send the URL. It's really up to the developers though, I don't personally have an interest in validation for the sake of validating. Aug 18, 2009 at 2:58
  • I'm kind of surprised that not a single wise guy has posted a regex yet ...
    – balpha StaffMod
    Aug 18, 2009 at 6:21
  • 2
    @balpha: That would lead to the obligatory link to Welbog's blog. Aug 18, 2009 at 7:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .