The:placeholder-shownpseudo-class selectsthe input đầu vào element itselfwhen placeholder text exists in a form input. Think of it as a nice way lớn distinguish between inputs that arecurrently showing placeholder textversus those that are not.
Bạn đang xem: Placeholder css là gì
input:placeholder-shown border: 5px solid red;
School Name:
Here’s a diagram:
I found this highly confusing as:
the specs only have:placeholder-shown& not::placeholder:placeholder-showncan still affect the styling of the placeholder text, since it’s a parent element (e.g. font-size).cảnh báo that:placeholder-shownis a pseudo-class(it’s an element in a particular state) and::placeholderis a pseudo-element(a visible thing that isn’t really in the DOM). Distinguishable by single-versus-double colons.
Xem thêm: Hướng Dẫn Cài Âm Thanh Cho Win 7, Download Cài Đặt Driver Âm Thanh Win 7
:placeholder-shown, being a pseudo-class, has to lớn select an existing element. It selects the đầu vào whenever you’re in the placeholder-showing state. The ::placeholder pseudo-element wraps the actual placeholder text.
If you need lớn style the placeholder textUse ::placeholder (actually, use all the crazy vendor prefixes for it) which we have detailed in the Almanac here.
More Information
47 | 51 | 11* | 79 | 9 |
90 | 87 | 90 | 9.0-9.2 |