On the main page of StackExchange sites, hovering over any question link produces a quick preview of the body of the question, which is a very nice feature. However, newlines in the body are reproduced as newlines in the hover-text source. This causes Firefox 3.6 to silently drop the newlines, mashing together text from different paragraphs in jarring, poorly-punctuated fashion (e.g. "… by clicking DraftsI'd like to see …", or "…deleted their own question?I provided an answer…"). It would be nice if the backend could replaced newlines with spaces instead.

  • Odd, the very same spec claims that the title attribute is %Text, and that <!ENTITY % Text "CDATA">? – Arjan Dec 23 '10 at 22:19

You're taking that part of the spec out of context. Here it is in full:

In certain cases, authors may specify the value of an attribute without any quotation marks. The attribute value may only contain letters (a-z and A-Z), digits (0-9), hyphens (ASCII decimal 45), periods (ASCII decimal 46), underscores (ASCII decimal 95), and colons (ASCII decimal 58). We recommend using quotation marks even when it is possible to eliminate them.

In other words, you're limited to that small set of characters (which, you should note, does not include spaces) iff you don't put the attribute in quotes.

A title attribute (the value being used here) should contain human readable text. This definition of CDATA says:

CDATA is a sequence of characters from the document character set and may include character entities. User agents should interpret attribute values as follows:

  • Replace character entities with characters,
  • Ignore line feeds,
  • Replace each carriage return or tab with a single space.

Given that, it's clear that line feeds, carriage returns, and tabs are valid characters.

What it appears you'd like is for SO to change their line feeds (per the spec, ignored by FF) to carriage returns (per the spec, converted into spaces). Is that correct?

  • Whoops, I think you're right. I've removed the part of the question talking about the HTML spec. – user152819 Dec 24 '10 at 5:25
  • I just checked Firefox's behavior, and it does follow the spec with respect to line feeds and carriage returns. So, yes to your last paragraph. – user152819 Dec 24 '10 at 5:29

Note that neither IE or Chrome or Safari have this behavior. They all display newlines in the title as, well, newlines. So I kind of consider this a bug in Firefox, honestly.

Opera also makes this mistake, but I expect softheadedness from Opera.

  • Two questions: (1) As Dori's answer notes, Firefox is merely following the HTML 4.01 spec. (2) Even if you disagree with the W3C and consider it a browser bug, is it your policy to not work around browser bugs? – user152819 Dec 24 '10 at 5:32

You must log in to answer this question.