pseudo element capabilities

Hey, is there anything that a pseudo element can't do that a normal element can? I know this is quite broad, but is there perhaps certain properties that wouldn't work on them etc? Thanks in advance.
16 Replies
MarkBoots
MarkBoots2mo ago
well, the contents of a pseudo element can not be read by a screenreader all other properties will probably work (but that's a broad answer as well)
snxxwyy
snxxwyyOP2mo ago
yeah that's true. is that about all the limitations you reckon?
MarkBoots
MarkBoots2mo ago
can not think of something else, but for a better answer, i need more
clevermissfox
clevermissfox2mo ago
You can’t give the content any HTML, it can take a string for example but can’t do something like this:
content;”This is a+ <span style=‘font-weight: 700;’>pseudo>/span> + “ element”;
content;”This is a+ <span style=‘font-weight: 700;’>pseudo>/span> + “ element”;
But you can use an attr for the content property which is a fun one !
snxxwyy
snxxwyyOP2mo ago
yeah that's fair enough. i was more just wondering about limitations oh yeah true, and then you can't style the attribute content seperately like in your example either. so i guess a limitation is being unable to style content content
Chris Bolson
Chris Bolson2mo ago
You can’t :hover ( or similar) on pseudo elements (not a property but worth taking into account)
snxxwyy
snxxwyyOP2mo ago
oh yeah, i'm pretty sure you can style them on hover of the parent though which is useful
ἔρως
ἔρως2mo ago
you cant attach events
snxxwyy
snxxwyyOP2mo ago
Oh with js?
ἔρως
ἔρως2mo ago
yup you also can't use it as an element in javascript you can access the styles set, but that's it
snxxwyy
snxxwyyOP2mo ago
Ah okay, I didn’t know that
ἔρως
ἔρως2mo ago
pseudo-elements are weird
Jochem
Jochem2mo ago
They're not quite in the DOM
snxxwyy
snxxwyyOP2mo ago
In what way? The fact they’re not in the accessibility tree?
Jochem
Jochem2mo ago
in that they're not accessible by JS because they're not really quite part of the DOM
snxxwyy
snxxwyyOP2mo ago
Ohh okay
Want results from more Discord servers?
Add your server