How to add text with css without pseudo-element


Tags: css

Problem :

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";
}


Solution :

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.


    CSS Howto..

    How can I set my unordered list to be in the middle not in-line (see image)?

    How can I position a web page in the middle of the screen?

    How to apply disabled style of ASP.net dropdownlist

    How to make a floated div 100% height of its parent?

    How to make parent fullscreen div to grow with absolutely positioned child using CSS and jeet?

    Using javascript to show html on every page except one page

    How to define text spacing in input in css

    How to edit the CSS of a div that does not contain a H1 tag?

    How to fix and re-arrange fixed position divs

    how to avoid overlapping of text

    CSS: how do I force contents in a table cell to stay on one line when browser size reduced

    How do you deploy a project using Less CSS to Heroku?

    How do I write a CSS for mouse hover [duplicate]

    CSS: On hover show and hide different div's at the same time? [duplicate]

    How to disable CSS Class on particular DIV

    How to fit the title to the entire page

    How can I make sure redundant

    tags do not break styling?

    How to make a webpage mobile friendly with css media queries

    How to create dynamic business listings in wordpress [closed]

    How to change custom icon image on hover of the link next to it?

    css how to depend one div to another one in auto adjusting width

    How to highlight the table row using jquery in Rails 3?

    CSS: How to add background-color with background-image under it (same color)

    How to use this CSS rule for divs? [JSFiddle]

    How to create a fixed menu (links come from right to left) - HTML & CSS

    How to handle text wrapping in CSS? [duplicate]

    How can i put two divs and one nav into the header at the top-left, top-center and top- right with css

    How to absolutely position element against page rather than floated parent?

    How to style author id in WordPress?

    How to position
    below rest of elements