Reputation: 9
Have this code in my HTML
<input name="Username" type="text" placeholder="Username" />
<input name="Password" type="text" placeholder="Password"/>
<input name="Button1" type="button" value="login" />
It works fine when I run it but for my assignment to get good marks, I have to use W3C validator. Is there anyway I can bypass that or fix?
Upvotes: 0
Views: 771
Reputation: 96707
You can’t use a placeholder
attribute in XHTML 1.0.
The placeholder
attribute was introduced with (X)HTML5. So if you want to use placeholder
, you have to switch to (X)HTML5.
HTML5 document that contains your snippet:
<!DOCTYPE html>
<title>Test</title>
<input name="Username" type="text" placeholder="Username" />
<input name="Password" type="text" placeholder="Password"/>
<input name="Button1" type="button" value="login" />
You can check it with https://validator.w3.org/nu/.
Upvotes: 0
Reputation: 18880
If you are trying to use placeholder text as a replacement for a label
, then no, there is no way around it and this is a good thing because placeholder text is not meant to replace a label
but to act as a helpful guide.
Add a label
.
Upvotes: 2