:-moz-placeholder

  • Revision slug: CSS/:-moz-placeholder
  • Revision title: :-moz-placeholder
  • Revision id: 71018
  • Created:
  • Creator: Sheppy
  • Is current revision? No
  • Comment fix typo; 1 words added, 1 words removed

Revision Content

{{ CSSMozExtensionRef() }}

{{ gecko_minversion_header("2.0") }}

Summary

:-moz-placeholder matches form elements displaying placeholder text. This allows web developers and theme designers to customize the appearance of placeholder text, which is a light grey color by default. This may not work well if you've changed the background color of your form fields to be a similar color, for example, so you can use this pseudo-class to change the placeholder text color.

Example

This example styles the placeholder text by making it green.

<!doctype html>
<html>
<head>
  <title>Placeholder demo</title>
  <style type="text/css">
    input:-moz-placeholder {
      color: green;
    }
  </style>
</head>
<body>
  <input id="test" placeholder="Placeholder text!" value="starting value">
</body>
</html>

View this example live.

Bugzilla

{{ Bug("457801") }}

Notes

Note: This was previously incorrectly documented as having been created for Gecko 1.9 {{ geckoRelease("1.9") }}, for an entirely different purpose.

{{ languages( { "ja": "ja/CSS/:-moz-placeholder" } ) }}

See also

  • Forms in HTML5
  • {{ HTMLElement("input") }}
  • {{ HTMLElement("textarea") }}

Revision Source

<p>{{ CSSMozExtensionRef() }}</p>
<p>{{ gecko_minversion_header("2.0") }}</p>
<h3 name="Summary">Summary</h3>
<p><code>:-moz-placeholder</code> matches form elements displaying <a href="/en/HTML/HTML5/Forms_in_HTML5#The_placeholder_attribute" title="en/HTML/HTML5/Forms in HTML5#The placeholder attribute">placeholder text</a>. This allows web developers and theme designers to customize the appearance of placeholder text, which is a light grey color by default. This may not work well if you've changed the background color of your form fields to be a similar color, for example, so you can use this pseudo-class to change the placeholder text color.</p>
<h3>Example</h3>
<p>This example styles the placeholder text by making it green.</p>
<pre class="brush: html">&lt;!doctype html&gt;
&lt;html&gt;
&lt;head&gt;
  &lt;title&gt;Placeholder demo&lt;/title&gt;
  &lt;style type="text/css"&gt;
    input:-moz-placeholder {
      color: green;
    }
  &lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
  &lt;input id="test" placeholder="Placeholder text!" value="starting value"&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>View this example live.</p>
<h3 name="Bugzilla">Bugzilla</h3>
<p>{{ Bug("457801") }}</p>
<h3>Notes</h3>
<div class="note"><strong>Note:</strong> This was previously incorrectly documented as having been created for Gecko 1.9 {{ geckoRelease("1.9") }}, for an <a class=" link-https" href="https://bugzilla.mozilla.org/show_bug.cgi?id=11011" title="https://bugzilla.mozilla.org/show_bug.cgi?id=11011">entirely different purpose</a>.</div>
<p>{{ languages( { "ja": "ja/CSS/:-moz-placeholder" } ) }}</p><h3 name="SeeAlso">See also</h3>
<ul> <li><a href="/en/HTML/HTML5/Forms_in_HTML5" title="en/HTML/HTML5/Forms in HTML5">Forms in HTML5</a></li> <li>{{ HTMLElement("input") }}</li> <li>{{ HTMLElement("textarea") }}</li>
</ul>
Revert to this revision