Quantcast
Viewing all articles
Browse latest Browse all 6

Hide element, but show CSS generated content

Is there a way of hiding an element's contents, but keep its :before content visible?Say I have the following code:

HTML:

<span class="addbefore hidetext">You are here</span>

CSS:

.addbefore:before {    content: "Show this";}.hidetext {    // What do I do here to hide the content without hiding the :before content?}

I've tried:

  • using display: none and setting display: inline on :before, but both are still hidden
  • using width: 0; overflow: hidden;, but then additional space seems to be added (?)
  • using color: transparent;, but then, of course, the content of the span still takes up space
  • using text-indent: -....px, but
    1. this is frowned upon by search engines and
    2. it seems not to work for span elements (?)

Any other ideas as to how I might do this?


Viewing all articles
Browse latest Browse all 6

Trending Articles