DEV Community

Discussion on: CSS-only floating label

Collapse
 
gwillz profile image
gwillz • Edited

I believe there is a way to get around the required requirement.
Use .form-control:not(:placeholder-shown) + .form-control-placeholder.

On another note, :pseudo + .sibling doesn't work in IE or Edge.

Collapse
 
peiche profile image
Paul

Since writing this, I have learned a lot about the :placeholder-shown pseudo-class. Thanks!

Collapse
 
thesheebs profile image
sheba

...and placeholder-shown is experimental and does not work with IE or Edge.
developer.mozilla.org/en-US/docs/W...

Collapse
 
gwillz profile image
gwillz

It gets worse.

IE has :-ms-input-placeholder as a selector for :placeholder-shown and Edge does not.

Whereas Edge has ::-ms-input-placeholder as an element for ::placeholder and IE does not.