Adding HTML entities using CSS content

后端 未结 9 1225
长情又很酷
长情又很酷 2020-11-22 06:57

How do you use the CSS content property to add HTML entities?

Using something like this just prints  

9条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-11-22 07:43

    Update: PointedEars mentions that the correct stand in for   in all css situations would be
    '\a0 ' implying that the space is a terminator to the hex string and is absorbed by the escaped sequence. He further pointed out this authoritative description which sounds like a good solution to the problem I described and fixed below.

    What you need to do is use the escaped unicode. Despite what you've been told \00a0 is not a perfect stand-in for   within CSS; so try:

    content:'>\a0 ';          /* or */
    content:'>\0000a0';       /* because you'll find: */
    content:'No\a0 Break';    /* and */
    content:'No\0000a0Break'; /* becomes No Break as opposed to below */
    

    Specifically using \0000a0 as  . If you try, as suggested by mathieu and millikin:

    content:'No\00a0Break'   /* becomes No਋reak */
    

    It takes the B into the hex escaped characters. The same occurs with 0-9a-fA-F.

提交回复
热议问题