placeholder次の属性を探しています。
<input placeholder="Your email address" />
JS フィドルのデモ。
テキストのスタイルを設定するにはplaceholder(対応ブラウザで):
::-webkit-input-placeholder,
::-moz-input-placeholder,
::-o-input-placeholder,
::-ms-input-placeholder,
::input-placeholder {
color: #0f0;
font-weight: bold;
}
JS フィドルのデモ。
テキストのスタイルを設定するには、それがvalue属性によるものか、ユーザーが入力したものかを問わず、通常colorの , font-style,font-weightなどを使用するだけです:
input {
color: #f00;
font-size: 1.5em;
font-style: italic;
font-weight: bold;
}
JS フィドルのデモ。
ちなみに、textareaあなたが正しく指摘しているように、 には「終了タグがあります」。したがって、それは自己終了 (または void) 要素ではなく、開始タグに文字を含めるべきではありません(/リンクされた JS Fiddle:<textarea id="style" name="message" />Type out your question here</textarea>で行うように)。代わりに、次のようにする必要があります。
<textarea id="style" name="message">Type out your question here</textarea>
または、次の場合placeholder:
<textarea id="style" name="message" placeholder="Type out your question here"></textarea>
また、 を使用しplaceholderて a を置き換えることlabelは、ユーザーがフィールドにフォーカスするか、フィールドにデータを入力すると、提供されるガイダンスが明示的に非表示になることを意味することにも注意してください。label要素を常に表示したくない場合は、inputがフォーカスされている間だけガイダンスを表示する 1 つの方法は次のとおりです。
label {
display: inline;
opacity: 0;
overflow: hidden;
-webkit-transition: all 1s linear;
-moz-transition: all 1s linear;
-o-transition: all 1s linear;
-ms-transition: all 1s linear;
transition: all 1s linear;
}
input:focus + label,
input:active + label {
opacity: 1;
-webkit-transition: all 1s linear;
-moz-transition: all 1s linear;
-o-transition: all 1s linear;
-ms-transition: all 1s linear;
transition: all 1s linear;
}
JS Fiddle demoinputがフォーカス/アクティブになると、公開がトリガーされます。