You can use a plain line break inside an attribute value:
<div data-foo="First line
Second Line">foo</div>
Browsers have been buggy in this respect, and the HTML specifications have not been quite clear on this; they discuss the meaning of line breaks in element content (where they are taking as equivalent to spaces), but not in attribute values. In HTML5 CR, the parsing rules for attribute values make it clear that line breaks are simply added to the attribute value. Modern browsers generally play by such rules.
However, when you use the value in CSS via attr(...)
, the line break will normally be treated as equivalent to a space, so you need to set white-space
on the pseudo-element to a value that makes line breaks honored, namely pre
, pre-wrap
, or pre-line
.
P.S. In HTML, the notation \a
is just two data characters, with no special meaning. The notation 

would denote a line break (specifically, LINE FEED), but it would be just equivalent to an actual line break in souce.
\a
works if you place it directly in thecontent: "First line \a Second Line";
but seemingly not if you pull it in viaattr()
. Wow, interesting question! – Lemuroid

entity. codepen.io/denilsonsa/pen/bgxKgP Summary: both solutions work on all modern browsers (Chrome, Firefox, Safari 9+, IE 11+). – Nathalia