Is it possible to select css generated content? [duplicate]

No, you can’t. See Selecting and manipulating CSS pseudo-elements such as ::before and ::after using jQuery. To repeat what is described there, generated content is not part of the DOM. In the words of the CSS2.1 spec, Generated content does not alter the document tree. Generated content only exists in the visual world of the … Read more

Why not :visited instead of a:visited for links?

TL;DR: At the time of writing, you are completely correct; there is no difference between a:visited and :visited. However, using a:visited is best practice for future-proofing your code. TL;DR EDIT: As of August 2016, the CSS4 Working Draft allows other tags to use :visited. There is now a functional difference between a:visited and :visited! Beware. … Read more

In CSS use “display:none” on the element, but keep its “:after”

No, it is not possible. Pseudo elements are rendered like children: <span id=”myspan”>whatever<after></span> And display:none hides the element including all children. EDIT 1 JavaScript is your best option in my opinion. Even without jQuery changing text is not hard: document.getElementById(“myspan”).innerHTML = “*”;​ Demo EDIT 2 However, if you really want to do it with CSS, … Read more

Can I make the CSS :after pseudo element append content outside the element?

The spec says: As their names indicate, the :before and :after pseudo-elements specify the location of content before and after an element’s document tree content. Note the key phrase at the end of this sentence, which refers to the inner content (or inner text). So, the pseudo-elements are inserted into the beginning of the end … Read more

Does the shadow DOM replace ::before and ::after?

CSS Scoping spec author here. The answer is actually, officially… undefined! I didn’t think about this interaction when I was writing the Scoping spec. I’ll send an email to the list, and we’ll figure it out. Almost certainly, we’ll settle on whatever browsers currently do (which appears to be letting ::before/after work “as expected” even … Read more

Can I target a :before or :after pseudo-element with a sibling combinator?

You can’t target :after since it’s content is not rendered in the DOM and it does not manipulate it – for this to work the DOM would have to be re-rendered and CSS can’t manipulate it like this. Check the specification for detailed understanding: http://www.w3.org/TR/CSS2/generate.html#propdef-content Generated content does not alter the document tree. In particular, … Read more