The placeholder text is usually displayed in a lighter shade of color than the <input> or <textarea> elements values.
In-order to add placeholder text to the <input> or <textarea> elements you will need to use the HTML5 placeholder attribute which must have a text value that contains no U+000A LINE FEED (LF) or U+000D CARRIAGE RETURN (CR) characters.
The placeholder attribute should not be used as an alternative to a label. For a longer hint or other helpful text, the title attribute would be more appropriate. Browsers that do not support the placeholder attribute will simply ignore it.
Here is how to code the placeholder attribute.
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Welcome To HTML5</title>
</head>
<body>
<form>
<input type="email" placeholder="email@example.com">
<textarea placeholder="Enter Optional Message"></textarea>
</form>
</body>
</html>
Here is how to code the placeholder attribute for XHTML5.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta charset="UTF-8" />
<title>Welcome To XHTML5</title>
</head>
<body>
<form>
<input type="email" placeholder="email@example.com" />
<textarea placeholder="Enter Optional Message"></textarea>
</form>
</body>
</html>
{ 0 komentar... Views All / Send Comment! }
Posting Komentar