Forum How do I...?

ISO character entity in a ::before pseudo-element

nick.perry
I have an xml source with the following content:
<para>Jane proclaimed <quote>I want to marry a Prince</quote>, and sighed a long sigh.<para>

and I want to add curly double quotation marks around the quote. To get this:
Jane proclaimed “I want to marry a Prince”, and sighed a long sigh.

I want to do something like this in the css:
quote::before {
  content: &ldquo;
}

but I just get nothing - same if referenced by unicode value. Pasting the actual uniode char between two standard double quotation marks causes Prince to fail - no doubt because the CSS is now no longer UTF-8 or ASCII.

Short of transforming the xml, can anyone offer a suggestion?

TIA
Nick
mikeday
Hi Nick,

You can use a CSS character escape like this:
quote::before {
    content: "\201C"
}

Alternatively, using an XML character entity should work if the CSS is within an XML file; ie. in the <style> element of an XHTML document:
<style>
quote::before {
    content: "&#x201C;"
}
</style>

Please note that if you use entities like &ldquo; you will need to ensure that they are declared by specifying an appropriate DOCTYPE declaration. For example, XHTML Transitional:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

Best regards,

Michael
nick.perry
Aha! Easy when you know how. Thanks for the tip, Mike.