Development CSS Content Generation: html enc characters?

Discussion in 'Software' started by relix, 4 Aug 2006.

  1. relix

    relix Minimodder

    Joined:
    14 Nov 2001
    Posts:
    5,948
    Likes Received:
    41
    I'm using CSS content generation to add nice quotes to my title, like this:

    “My Title”

    Notice they are skewed and so I can't use "open-quote" and "close-quote" since those are straight.

    This is the specific code:
    Code:
    .frontlist_item .content h1:before { 
    	content: "“"
    }
    .frontlist_item .content h1:after {
    	content: "”"
    }
    
    As you can see I'm using HTML-encoded characters for this, but apparantly that's not allowed in CSS, since now my titles look like this:

    “My Title”

    The html-encoding just ain't translated. I tried just putting the character straight in there (like content: "”"), and this worked locally, but when I put the code on my server, weird characters appear in the browser, instead of the quotes.

    If someone can help me out with this it'd be greatly appreciated.
     
  2. Firehed

    Firehed Why not? I own a domain to match.

    Joined:
    15 Feb 2004
    Posts:
    12,574
    Likes Received:
    16
    It should be allowed... perhaps you haven't defined your doctype or something of that nature? I convert all of my database output to use the html-encoded characters by htmlentities($data, ENT_QUOTES), and it outputs just that type of thing.
     
  3. will.

    will. A motorbike of jealousy!

    Joined:
    2 Mar 2005
    Posts:
    4,461
    Likes Received:
    20
    Is content: supported by all browsers? I heared that it did bad things to older versions of ie and opera...
     
  4. relix

    relix Minimodder

    Joined:
    14 Nov 2001
    Posts:
    5,948
    Likes Received:
    41
    Firehed:
    I'm including the stylesheet with <link rel="stylesheet" type="text/css" href="main.css" /> and have no headers in the css file (don't think there are any anyway?).
    The doctype I'm using (generated by Bluefish): <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/xhtml1-strict.dtd">

    Will:
    It worked for me under Safari, Shiira, Opera 8, 9, IE 6, Firefox
    Wouldn't surprise me if it didn't work for IE 5, but that's allright, it's not that those quotes will make a life's differince...

    Also, if I include &ldquo; directly in the html, it does work.
     
  5. relix

    relix Minimodder

    Joined:
    14 Nov 2001
    Posts:
    5,948
    Likes Received:
    41
    Fixed!

    I had to use the "CSS-style" encoding, and these are apparntly: \201C for left double quotes, and \201D for right double quotes.

    Thanks for your help all!
     
  6. OneSeventeen

    OneSeventeen Oooh Shiny!

    Joined:
    3 Apr 2002
    Posts:
    3,454
    Likes Received:
    2
    Good to know!

    Thanks for posting your solution here, too many people just say "I figured it out" without posting what made it work.

    So IE6+ even understands these? Cool! Are they part of the W3C standard for CSS 2?
     
  7. relix

    relix Minimodder

    Joined:
    14 Nov 2001
    Posts:
    5,948
    Likes Received:
    41
    I thought it did work with IE6 but I'm not sure.
    Yes, they are very much a part of the W3C standard for CSS 2. Other great things one can do with content generation is using counters, for example to colour even rows in a table differintly than uneven ones. Definetly worth checking out, it helps even seperate content from design even more, which is always A Good Thing (tm) :)
     
  8. [Jonny]

    [Jonny] What's a Dremel?

    Joined:
    1 Sep 2003
    Posts:
    296
    Likes Received:
    0
    I'm pretty much 100% certain that IE supports neither content or the :before selector. Have you tested it? :)
     
  9. SJH

    SJH Minimodder

    Joined:
    24 Dec 2003
    Posts:
    1,427
    Likes Received:
    5
    Jonny's right I'm afraid!
     
  10. Firehed

    Firehed Why not? I own a domain to match.

    Joined:
    15 Feb 2004
    Posts:
    12,574
    Likes Received:
    16
    I'd wager a guess that it didn't work (with standard codes) because you used XHTML strict instead of the more often-used transitional. Just a guess though, seeing as I'm well overdue for some sleep now. Stupid cool white lightbulbs make you forget it's night since it's not all yellow and artifical-looking :hehe:
     
  11. relix

    relix Minimodder

    Joined:
    14 Nov 2001
    Posts:
    5,948
    Likes Received:
    41
    Firehed: could very possible be, indeed!
    Jonny, no, I didn't test it, so you could be right.
     

Share This Page