Answer by dj.cowan for Hide element, but show CSS generated content
2025 updateVisual 'manipulation' of the DOM using display: contents which plays nicely with grid/flex.Taken from the following stackoverflow question/answer:What does display:contents do?With...
View ArticleHide 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...
View ArticleAnswer by Sotiris for Hide element, but show CSS generated content
I don't think it's possible with pure css and html. Looking at this example http://jsbin.com/efeco4 you will see that what is inside content property of css, is wrapped by the element. So any...
View ArticleAnswer by anroesti for Hide element, but show CSS generated content
Clean SolutionYou could use visibility: hidden, but with this solution, the hidden content will still take up space. If this doesn't matter to you, this is how you would do it:span { visibility:...
View ArticleAnswer by tinystride for Hide element, but show CSS generated content
For better browser support:Wrap the text that should be hidden within an additional span element, and apply classes to that span to hide the text you wish to be hidden.HTML:<span...
View ArticleAnswer by EoghanM for Hide element, but show CSS generated content
Building on @anroesti's excellent hack, here's a solution if you need to apply in unknown contexts in terms of font size and color, i.e. you are not sure if resetting to color:black;font-size:1rem;...
View ArticleAnswer by Brenden for Hide element, but show CSS generated content
I took a similar approach as suggested here with visibility, but that still has a content box.My solution is to simply use font-size to hide the target text.span { font-size: 0;}span:before {...
View Article