Search code examples
htmlcsscss-selectorspseudo-class

Can a CSS pseudo-class be declared on an HTML element?


Is it possible to set a CSS pseudo-class on an HTML element? In this particular case, I would like a certain <div> to have the last-child property.

I asked myself this question when IE11 wouldn't recognize a specific <div> as a last-child while other browsers did. I have found a work around and at this point I just want to know whether setting a pseudo-class on an HTML element can be done.

A coworker suggested this may be in fact done using React framework. However, I have not been able to find anything suggesting this is possible.


Solution

  • No.

    Pseudo-classes are used to define the state of an element.