User Agent: Mozilla/5.0 (Windows NT 6.2; WOW64; rv:28.0) Gecko/20100101 Firefox/28.0 (Beta/Release) Build ID: 20140314220517 Steps to reproduce: When a data-attribute contains a "\A" to have the content show on multiple lines, it does not render the same as when the content is explicitly set. See this jsFiddle to make this more clear: http://jsfiddle.net/96pwE/ Actual results: when "content: attr(data-zzz)" is used, the "\A" within the data-zzz attribute is rendered as plain text Expected results: The "\A" should be treated like a carriage return when the white-space is set to pre
http://www.w3.org/TR/CSS21/generate.html#propdef-content says: attr(X) This function returns as a string the value of attribute X for the subject of the selector. The string is not parsed by the CSS processor.
> http://www.w3.org/TR/CSS21/generate.html#propdef-content says: That's old, of course. https://developer.mozilla.org/en-US/docs/Web/CSS/attr says with the default type, string, "the attribute value is parsed as a CSS <string>", which supports escaping. https://developer.mozilla.org/en-US/docs/Web/CSS/string Reproduced with 2014-04-02-03-02-01-mozilla-central-firefox-31.0a1.en-US.linux-x86_64
Though https://developer.mozilla.org/en-US/docs/Web/CSS/white-space says "pre" means "sequences of whitespace are preserved, lines are only broken at newline characters in the source and at <br> elements." Is that "\A" a newline character in the source?
http://www.w3.org/TR/css3-values/#attr-notation (found in bug 435426) says it "does not reparse". Maybe the developer.mozilla.org article is wrong at the time.
Webkit doesn't support this either, but I think it would make sense to have content work consistently with either a string or attr(X).
That devmo page is quoting an old spec draft, which didn't say what it meant to say. There is no reparsing that's supposed to happen here. If you want to embed a newline in your attribute, you just do that (either via explicit newlines, HTML escapes, \n in a JS call to setAttribute, whatever). I've fixed the devmo page.
> "\n" doesn't work either You forgot white-space: pre on the tests after test1. I fixed you fiddle to show a number of different ways of putting in a newline. See http://jsfiddle.net/96pwE/5/ > Which demo page did you fix? I fixed the documentation quoted in comment 2.