2012-09-19 42 views
0

這個HTML是不是出於某種原因的工作...HTML代碼不工作

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 

<html xmlns="http://www.w3.org/1999/xhtml" lang="en"> 
    <head> 
     <meta http-equiv="Content-type" content="text/html;charset=UTF-8"/> 
     <title>Gallery</title> 
     <!-- 
     <link rel="stylesheet" type="text/css" href="gallery.css"/> 
     Note: use if stylesheet is separated from main project 
     I am embedding the CSS so it is easier to send 
     --> 
     <!-- 
     <script type="text/javascript" src="gallery.js"></script> 
     Note: use if javascript is separated from main project 
     I am embedding the JS so it is easier to send 
     --> 
     <style> 
      /* CSS */ 
      #topbar {} 
      #selection {border: 3pt solid red;} 
     </style> 
     <script type="text/javascript"> 
      // Javascript 
     </script> 
     <!-- JQuery --> 
     <script src="http://code.jquery.com/jquery-1.8.1.min.js" type="text/javascript"/> 
    </head> 
    <body> 
     <div id="topbar"> 
      <table id="selection"> 
       <tr> 
        <td>Test1</td> 
       </tr> 
      </table> 
     </div> 
    </body> 
</html> 

body沒有顯示出來!我甚至試圖用一些文字隨機附上<p>,但沒有出現。問題是什麼?

回答

8

您需要關閉您的<script>標記。自閉標籤與<script>元素無效:

<script src="http://code.jquery.com/jquery-1.8.1.min.js" type="text/javascript"></script> 
+0

哦,傻我。謝謝!堆棧溢出讓我接受答案。 – Doorknob

+0

「自我關閉標籤」是有效的(正如您在文檔中使用http://validator.w3.org所看到的),它們只是不起作用(它們被簡單識別爲開始標籤),因爲XHTML文檔實際上是通過瀏覽器中的HTML規則進行處理(除非使用XML內容類型進行發送,這會導致IE窒息)。這就是爲什麼XHTML 1.0中的兼容性指南針對它們的建議:http://www.w3.org/TR/xhtml1/#guidelines –