HTML placeholder attribute is not a valid attribute

10.7k views Asked by At

On SharePoint application page I am using placeholder in <input> like this:

<input type="text" id="name" name="name" placeholder="your name" />

But placeholder is underlined and says: Validation (XHTML 1.0 transitional) Attribute placeholder is not a valid attribute. But when i put runat = "server", error goes away

<input type="text" id="name" name="name" placeholder="your name" runat="server" /> 

Now, its valid attribute. I could not understand why placeholder attribute is not valid without runat = "server". Can anybody tell the reason? I did not want to use runat = "server".

I have also added <!DOCTYPE html>at top of the application page, but still it gives same error

2

There are 2 answers

2
Muhammad Talha Akbar On BEST ANSWER

You are using HTML5 markup, with XHTML 1.0 Transitional doctype

placeholder, article, footer, etc are all HTML5

<!DOCTYPE html>

Above is the appropriate DOCTYPE for HTML5.

0
Austin Brunkhorst On

placeholder is a HTML5 attribute, Therefore it shouldn't be valid under xHTML 1.0 Transitional. As for the runat attribute changing the behavior, it's most likely a flaw in the system or just being suppressed for some reason.