Inspect webkit-input-placeholder with developer tools
To style and inspect the ::webkit-input-placeholder
, follow these steps:
1. Open your browser's dev tools (F12
/ right-click
> Inspect
).
2. Select the input
or textarea
in the Elements panel.
3. Enable:hov state in the Styles pane.
4. Inspect :placeholder
to view placeholder styles.
Quick reference to style placeholders:
This code snippet changes the placeholder text to red and bold.
Unraveling the Shadow DOM
To gain deeper insights, venture into the Shadow DOM. It houses styles that are hidden by default. To unveil them:
1. Open the DevTools settings (gear icon
on the top-right corner or F12 -> F1
).
2. Find the "Preferences" tab and locate the "Elements" section.
3. Enable 'Show user agent shadow DOM'. Voila! Placeholder styles are now visible in the Elements panel.
A Detective's Playground
Investigate placeholders by accessing specific styles. Once you've enabled Shadow DOM, you can:
- Identify exact color values, including the alpha channel, directly. No need for additional tools! Goodbye, Photoshop 👋
- Understand how to override default styles with personalized CSS.
Quick Detective Tools
Why walk when you can run? Use this shortcut for faster debugging:
Cmd/Ctrl + Shift + C
to activate the DevTools in inspect mode and then select theinput
box.
Cross-Browser Compatibility
Remember that not all browsers sing the same song. Here's a cheat-sheet for different browsers:
- Mozilla's star, Firefox, goes by
::placeholder
. - Internet Explorer has it's own act:
:-ms-input-placeholder
. - And
::webkit-input-placeholder
hits the notes for both Safari and Chrome, though vendor prefixes may influence the proceedings.
Future Proofing
Web development is like a river, it never stops flowing. Keep your skills afloat:
- This guide is cooked with Chrome 69. Ingredients may change in future versions.
Was this article helpful?