Why is this JavaScript not getting rendered correctly when outputted as HTML?
var innerHtml =
"<div style='color:yellow;font: 14px//14px /'Lucida Grande/',sans-serif;'>";
Am I not escaping something correctly?
/ should be \
var innerHtml =
"<div style=\"color:yellow;font: 14px/14px 'Lucida Grande',sans-serif;\">"
font uses font-size/line-height, no backslashes necessary.You don't need to escape forward slashes (/), nor do you need to escape single quotes (') (as you're quoting with double quotes "). The backslash is the escape character (\)
var innerHTML = '<div style="color:yellow; font: 14px/14px "Lucida Grande", sans-serif;">';
should work. I used single quotes as I prefer to have HTML output use double quotes (not that it matters in JavaScript, but it's a consistency thing).
Edit to HTML escape the font-family quotes.
font-face quotes be escaped since the same type of quotes are used for the entire style declaration?