Reputation: 3999
I want to add text just with css. But pseudo-elements are not option. Point is to add text just with css, and have text in DOM.
Is that posssible ?
So this is not option :
.someClass:before {
content: "some text";
}
Upvotes: 0
Views: 1797
Reputation: 8254
In general, the entire purpose of CSS is to preserve the distinction between style/design and content. The pseudo-selectors are a little unique in that they don't select actually existing content to "style" it, but rather create the content in the first place.
This doesn't exactly interfere with the purpose of CSS because the distinction between content and design can sometimes get a little fuzzy. Cf., for example, http://css-tricks.com/css-content/ which talks of how appending "E-mail: " before every email address can actually be a style decision.
That said, I really don't understand why you don't want to use pseudo-elements. Support is near ubiquitous (http://css-tricks.com/browser-support-pseudo-elements/). Your only other option would be to use JS/jQuery or good ol' HTML.
Upvotes: 5
Reputation: 11750
Cascading Style Sheets (CSS) is a simple mechanism for adding style (e.g., fonts, colors, spacing) to Web documents. (w3org)
You can not add any content without the use of :before or :after
In order to edit the DOM consider using jQuery or any other js script:
jQuery:
$('body').append('<div>Your new content</div>');
Upvotes: 1