HTML< option>的最佳做法; :已选择VS已选择=“已选择" [英] Best practice for HTML <option> : selected VS selected="selected"
本文介绍了HTML< option>的最佳做法; :已选择VS已选择=“已选择"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在<select>
中预先选择<option>
的最佳实践是什么?
What is the best practice to pre-select an <option>
in a <select>
?
根据不同的网站,两者均有效.但是哪个更好?最兼容?
According to different websites, both works. But which one is better? the most compatible?
<option selected="selected">Foo</option>
<option selected>Bar</option>
推荐答案
如果您正在编写XHTML,则需要selected="selected"
.
If you are writing XHTML, selected="selected"
is required.
如果您正在编写HTML,则selected
会减少击键次数和字节数.
If you are writing HTML, selected
is fewer keystrokes and fewer bytes.
两者都与浏览器没有更好的兼容性.
Neither has better compatibility with browsers.
这篇关于HTML< option>的最佳做法; :已选择VS已选择=“已选择"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文