Placeholder VS Label for input in HTML5

三世轮回 提交于 2019-11-30 12:02:24

HTML validators will not check accessibility. Valid HTML can still be inaccessible or less than optimal. Labels are still important and HTML5 placeholder is not a replacement for them. See H44: Using label elements to associate text labels with form controls in the WCAG 2 Techniques. If your layout requires that the label not be visible to sighted users, you can always include the label but move it offscreen with negative margins/text-indent.

Update:

Some test result on placeholder and a discussion on the W3 Public HTML mailing list about using placeholder without label.

Placeholder is no replacement for Label so I guess for screen reader this should be present or at least set the title attribute. Ref

For cross browser compatibility you need to use javascript. Checkout http://www.hagenburger.net/BLOG/HTML5-Input-Placeholder-Fix-With-jQuery.html for that.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!