[問題] doctype 和 external css

看板Web_Design作者 (林帛亨加油!!!)時間15年前 (2011/04/22 00:21), 編輯推噓1(102)
留言3則, 3人參與, 最新討論串1/1
剛開始學習html和css 本來都用internal css 想說來練習用external的形式 結果就出問題了 開初來的網頁會好像根本沒吃到.css 在我反覆的測試下發現 把DOCTYPE刪掉的話 可以正常運行 /*=====test1.html=====*/ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "" rel="nofollow">http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="" rel="nofollow">http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title>test2</title> <link href="style.css" type="text/css" rel="stylesheet" /> </head> <body> <h1>Test Test Test</h1> <p>1234567890</p> </body> </html> /*=====style.css=====*/ body { background:#ff0000; } 兩個檔案我放在同樣的資料夾下 照上面這樣打 背景會是白色的 如果把DOCTYPE刪掉 背景就會是紅色的 想請問一下是哪邊出錯了 謝謝 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 114.32.15.242

04/22 09:23, , 1F
background改成background-color呢?
04/22 09:23, 1F

04/22 11:21, , 2F
我在 chrome , IE8 都可以看到背景是紅色的 0.0..
04/22 11:21, 2F

04/22 12:19, , 3F
睡醒再開就正常了@@
04/22 12:19, 3F
文章代碼(AID): #1Di5cLWb (Web_Design)