tags:

views:

76

answers:

3

Can I write some style css code for every • code I use in my page, for example font-size: 16px;? Thanks.

+4  A: 

No, you cannot. You cannot style text content, no matter how it’s encoded (either as direct characters or as entities).

The closest thing you can do is put <span class="bullet">•</span> into the document and style the class bullet.

Konrad Rudolph
A: 

No. With CSS you can only address elements but not certain characters (ok, there are exceptions like :first-letter). You would need to put it into an element like span:

<span class="bullet">&#8226;</span>

Then you can use the selector span.bullet to style these elements:

span.bullet {
    font-size: 16px;
}
Gumbo
+1  A: 

Others have answered the main question; you cannot specify a CSS Rule based on text content (just on HTML elements, classes, and ids).

What you could do is use Javascript, or server-side rendering to do a .Replace() to wrap the character with the necessary HTML tags (replace just the character with a wrapped version of the character).


Here's a quick proof-of-concept; it could easily avoid the jQuery (it's a crutch of mine), and you might play around a bit with how the character is encoded in the Javascript (I had to copy/paste it in to work).

The key portion is:

.replace("•","<span class='bullet'>•</span>")
STW