quotes in CSS :after element

This question already has an answer here:

  • Adding HTML entities using CSS content 9 answers
  • How can I escape single or double quotation marks in CSS? 2 answers

  • You can escape the single quote: http://jsfiddle.net/NKHaQ/1/

    .foo:after{
       content: '7'4';
    }
    

    Alternatively, you could double-quote the value:

    .foo:after{
       content: "7'4";
    }
    
  • Specification
  • Double quotes cannot occur inside double quotes, unless escaped (as """ or as "22"). Analogously for single quotes (''' or '27').

    content: "this is a 'string'.";
    content: "this is a "string".";
    content: 'this is a "string".';
    content: 'this is a 'string'.';
    

    You can also do this: http://jsfiddle.net/NKHaQ/4/

    .foo:after{
       content: '727 4';
    }
    

    However—in addition to being harder to read—this creates the potential for a subtle problem. If you omit the space after 27 , it runs together with the 4 , which is then parsed as 274 , which gives the wrong output.

    链接地址: http://www.djcxy.com/p/15536.html

    上一篇: CSS将html实体作为内容

    下一篇: 在CSS中的引号:在元素之后