Home  >  Article  >  Web Front-end  >  Why Doesn\'t ::after Work on Elements?

Why Doesn\'t ::after Work on Elements?

Mary-Kate Olsen
Mary-Kate OlsenOriginal
2024-10-25 13:34:02388browse

Why Doesn't ::after Work on  Elements?

Mystery of the Vanished ::after

In the realm of CSS pseudo-elements, the ::after property is a powerful tool for injecting additional content into the DOM. However, it has been discovered that browsers curiously refuse to honor ::after on elements.

This seemingly inexplicable behavior has left web developers scratching their heads. According to the CSS21 Specification at http://www.w3.org/TR/CSS21/generate.html, ::after is designed to operate on elements with (document tree) content.

A closer examination reveals that lacks any such document tree content, just like and
. Consequently, browsers adhere to the specification by not displaying ::after for input fields. This explains the disappearance of the intended content in the provided code sample.

The above is the detailed content of Why Doesn\'t ::after Work on Elements?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn