267

I'm relatively new to CSS, and have used it to change the style and formatting of text.

I would now like to use it to insert text as shown below:

<span class="OwnerJoe">reconcile all entries</span>

Which I hope I could get to show as:

Joe's Task: reconcile all entries

That is, simply by virtue of being of class "Owner Joe", I want the text Joe's Task: to be displayed.

I could do it with code like:

<span class="OwnerJoe">Joe's Task:</span> reconcile all entries.

But that seems awfully redundant to both specify the class and the text.

Is it possible to do what I'm looking for?

EDIT One idea is to try to set it up as a ListItem <li> where the "bullet" is the text "Joe's Task". I see examples of how to set various bullet-styles and even images for bullets. Is it possible to use a small block of text for the list-bullet?

abelenky
  • 63,815
  • 23
  • 109
  • 159
  • 1
    the
  • idea isn't good practice. If you really want to this, look into a templating language instead.
  • – Gary Apr 29 '10 at 23:16
  • 1
    Sounds like using the CSS3 :before or :after pseudo-elements you'll really just be moving the redundancy to CSS land (because you'll need to add a CSS statement for OwnerJoe, OwnerJane, etc.) – Matt Beckman Apr 29 '10 at 23:25
  • 2
    @Matt Beckman: That is fine with me. I can easily define CSS blocks for each of my users. Repeating it over and over in the HTML seems excessive in my case. – abelenky Apr 29 '10 at 23:33
  • 1
    I feel like a more practical use of this for wider audience would be like `label.required:before {content: "* ";}` to add an asterisk in front of required fields, perhaps. – Patrick Jun 13 '13 at 16:16