I have CSS code like this:
:-moz-placeholder,::-moz-placeholder {
color: #999;
/*some additional font styling*/
}
I can click "Inspect element" and see all style information about element. But where I can see all CSS rules that has applied to element placeholder?
The ::placeholder pseudo-element represents placeholder text in an input field: text that represents the input and provides a hint to the user on how to fill out the form. For example, a date-input field might have the placeholder text YYYY-MM-DD to clarify that numeric dates are to be entered in year-month-day order.
Check the "Show user agent shadow DOM" checkbox and reload your page. You should now see the placeholder html output in your dev tools when you view the elements tab. Clicking on the placeholder html will bring up the applied styles for you to view or edit.
The “placeholder” property is used to get or set the placeholder of an input text. This can be used to change the placeholder text to a new one. The element is first selected using a jQuery selector. The new placeholder text can then be assigned to the element's placeholder property.
Placeholder is a pseudo-element, like ::before and ::after (https://developer.mozilla.org/en-US/docs/Web/CSS/Pseudo-elements) sometimes refered as pseudo-class (https://developer.mozilla.org/en-US/docs/Web/CSS/pseudo-classes)
These types of elements could not be seen in the Firefox Inspector, you needed at least Firebug or Chrome Dev Tools, but recently it's available in the Firefox Inspector, too. They are part of the "shadow dom" (extreme simple description: elements created by the browser inside of other elements).
You should be able to find the placeholder in the dom inspectors inside your input or textarea elements, e.g. select an input element, then choose "inspect element" from right click menu, then you should see something like that:
Firefox Inspector
Chrome Dev Tools
For Chrome you may need to enable "Show user agent shadow DOM" in the Dev Tools settings.
Just to give an updated answer for anyone still coming to this page, in FireFox v66, you can reveal pseudo-element styles simply by clicking on the expand icon in the styles panel when inspecting an element in the Developer Tools- see screenshot:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With