Best practice for HTML <option> : selected VS selected=“selected”

穿精又带淫゛_ 提交于 2019-12-03 23:35:21

If you are writing XHTML, selected="selected" is required.

If you are writing HTML, selected is fewer keystrokes and fewer bytes.

Neither has better compatibility with browsers.

According to the HTML4 standard, using selected implies it is selected="selected". So the standard already defines both are supported. Their code sample already includes a code block just using selected.

For compatibility with XHTML (specifically XML is the 'problem' here), there is a selected="selected" option.

HTML5 also defines selected on its own is valid, so no need to worry.

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