1

I'm wondering if it's possible to have certain pieces of 'static' text in the css3 instead of in the HTML, just like one can also have 'background-image' in css3 ?

I have searched on Google but cannot seem to find any reference to this.

2
  • What is your use case?
    – weiglt
    Commented Sep 17, 2013 at 19:00
  • Short answer: no. Longer: CSS is styling information. HTML is content information. static text is content, thus it is part of the HTML.
    – DwB
    Commented Sep 17, 2013 at 19:01

2 Answers 2

2

Pseudo selectors like :before and :after can specify a content property, which can be text.

p:before {
  content: "this will appear before all paragraph content";
}
1

Put simply, no, not like a background-image.

You may use :before/:after selectors with the content property, but that wouldn't work like a background image, it would place the text either before or after the element.

Fiddle demo: http://jsfiddle.net/YkerN/ and support table: http://caniuse.com/#feat=css-gencontent (IE8+; no problems in other browsers)

Not the answer you're looking for? Browse other questions tagged or ask your own question.