Let's say I have mark up:
<div data-generated="world!">Hello </div>
..with CSS:
div:after {
content: attr(data-generated);
}
This produces the text: Hello world! - FIDDLE
div:after {
content: attr(data-generated);
}
<div data-generated="world!">Hello </div>
BUT...
If I try to select / Copy the text - only the 'hello ' part is selectable.
Is there any way to select css generated text?
NB:
1) I have looked at the spec (here and here) regarding generated content and I haven't seen any reference to this issue.
The spec here and here seems to say that generated content should be selectable
Generated content should be searchable, selectable, and available to assistive technologies
2) If the answer to this question is 'no - it is not possible' - please link to a credible source which states this.
content
element in using it in this way. If you want actual selectable 'content' the use a proper HTML element not a pseudo element. - developer.mozilla.org/en-US/docs/Web/CSS/Pseudo-elements – Cairistiona<div data-commentcount="3"> comments </div>
is an acceptable usage either. CSS shouldn't be used to generate content, but styles. Writing "3" here is not considered a style, but actual content. If you tried to add some fancy quotes or bullt point, then it would be a style. Besides, what benefit does that give you over just including "3 comments" as a text? – Kep