[html]span里面放div会带来严重问题

2017-07-27  本文已影响50人  清水芦苇

If you use the W3C Validator to check a simple document:

<!DOCTYPE html> 
<html lang="en">    
<head>      
 <title>Title</title>      
 <meta charset="utf-8">    
</head>   
<body>      
<span>         
    <div><p>Some text</p></div>         Some text      
</span>   
</body></html>

it does not report an error when validating it as HTML5. If you set the doctype to "HTML 4.01 Transitional" it does. Perhaps this is just because the HTML5 validation is experimental?
The html5.validator.nu service does report an error however

参考文献

  1. http://stackoverflow.com/questions/2919909/nesting-div-within-span-problem
  2. http://diophung.blogspot.jp/2014/03/web-developer-conform-to-w3c-standards.html
  3. http://doctype.com/span-contain-div-html5
  4. https://www.w3.org/wiki/Generic_containers_-_the_div_and_span_elements
  5. https://www.w3.org/TR/html401/struct/global.html#h-7.5.3
上一篇 下一篇

猜你喜欢

热点阅读