看板 Ajax 關於我們 聯絡資訊
題外話,到底需不需要「/>」?用 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
scribeTW:講結論: HTML 不需要, XHTML/XML 要 05/04 23:26
hougzou:總之... 努力寫成well formed xml就對了! 05/04 23:29
tomin:寫成<foo></foo>比較好吧? 有時<foo/>會有問題 05/04 23:44
chrisQQ:個人習慣會是 <tag attr="value" /> 感覺 "value"/> 小怪 05/05 05:11
chrisQQ:不過也只是習慣問題… 一般來說有內文的才需要<tag></tag> 05/05 05:12
chrisQQ:沒內容的像 img 這類的,用 /> close 應該就可以了 05/05 05:12
chrisQQ:btw 不知道 <foo/> 什麼情況會有問題?可以提出參考一下嘛 05/05 05:13
chrisQQ:想瞭解一下以後遇到才好避免做這種無意義的debug... 05/05 05:14
KC73:如果是 html,<img src='xxx' alt=''> 就可以了. 05/05 08:51
KC73:xhtml 才需要 <img ... /> 05/05 08:51
KC73:同理,html 的話 <br> 即可,無需 <br/> 05/05 08:51
KC73:/> 的話,/ 都會被 Firefox 塗成紅色的。 05/05 08:54
tomin:印象中IE捉得到<div id=a></div> 但<divi id=a />捉不太到 05/05 11:46
tomin:當然其他瀏覽器<div/>是正常的 或許div, span這種比較特別? 05/05 11:47
TonyQ:其實最有問題的是 script 一定要有end tag 05/05 12:01
chrisQQ:原來如此,感謝 tomin !! 05/06 07:48