html - Is it possible to select css generated content? -
this question has reply here:
how can create generated content selectable? 2 answerslet's have mark up:
<div data-generated="world!">hello </div>
..with css:
div:after { content: attr(data-generated); }
this produces text: hello world! - fiddle
but...
if seek select / re-create text - 'hello ' part selectable.
is there way select css generated text?
note:
1) have looked @ spec (here , here) regarding generated content , haven't seen reference issue.
2) if reply question 'no - not possible' - please link credible source states this. edit:
some users pointed out misusing info attributes.
well, ok maybe in above example.... utilize this:
<div data-commentcount="3"> comments </div>
fiddle
...where data-commentcount attribute set in javascript.
this certainly acceptable usage isn't it.... otherwise attr() function for?
no, can't.
see manipulating css pseudo-elements using jquery (e.g. :before , :after). repeat described there, generated content not part of dom.
in words of css2.1 spec,
generated content not alter document tree.
generated content exists in visual world of rendering engine. selecting selecting portions of dom. generated content not in dom, hence cannot selected. same reason, generated counters or list item bullets cannot selected.
html css selection pseudo-element css-content
No comments:
Post a Comment