作者KC73 (肯先生)
看板Ajax
标题Re: [问题] Javascrip onClick参数
时间Tue May 4 23:23:03 2010
题外话,到底需不需要「/>」?用 W3C validation 跑的结果:
Below is a list of the warning message(s) produced when checking your
document.
Line 85, Column 35: NET-enabling start-tag requires SHORTTAG YES
<input type='button' value='test'/>
The sequence <FOO /> can be interpreted in at least two different ways,
depending on the DOCTYPE of the document. For HTML 4.01 Strict, the '/'
terminates the tag <FOO (with an implied '>'). However, since many browsers
don't interpret it this way, even in the presence of an HTML 4.01 Strict
DOCTYPE, it is best to avoid it completely in pure HTML documents and reserve
its use solely for those written in XHTML.
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 118.166.130.232
1F:推 scribeTW:讲结论: HTML 不需要, XHTML/XML 要 05/04 23:26
2F:→ hougzou:总之... 努力写成well formed xml就对了! 05/04 23:29
3F:推 tomin:写成<foo></foo>比较好吧? 有时<foo/>会有问题 05/04 23:44
4F:→ chrisQQ:个人习惯会是 <tag attr="value" /> 感觉 "value"/> 小怪 05/05 05:11
5F:→ chrisQQ:不过也只是习惯问题… 一般来说有内文的才需要<tag></tag> 05/05 05:12
6F:→ chrisQQ:没内容的像 img 这类的,用 /> close 应该就可以了 05/05 05:12
7F:→ chrisQQ:btw 不知道 <foo/> 什麽情况会有问题?可以提出参考一下嘛 05/05 05:13
8F:→ chrisQQ:想了解一下以後遇到才好避免做这种无意义的debug... 05/05 05:14
9F:→ KC73:如果是 html,<img src='xxx' alt=''> 就可以了. 05/05 08:51
10F:→ KC73:xhtml 才需要 <img ... /> 05/05 08:51
11F:→ KC73:同理,html 的话 <br> 即可,无需 <br/> 05/05 08:51
12F:→ KC73:/> 的话,/ 都会被 Firefox 涂成红色的。 05/05 08:54
13F:推 tomin:印象中IE捉得到<div id=a></div> 但<divi id=a />捉不太到 05/05 11:46
14F:→ tomin:当然其他浏览器<div/>是正常的 或许div, span这种比较特别? 05/05 11:47
15F:→ TonyQ:其实最有问题的是 script 一定要有end tag 05/05 12:01
16F:→ chrisQQ:原来如此,感谢 tomin !! 05/06 07:48