我正在運行lynx
來測試我必須做的一些HTML,因爲考慮到可訪問性。我猜想,如果Lynx看起來很漂亮,那麼屏幕閱讀器,蹩腳手機和其他東西的整個範圍都可以,甚至是大多數古老的硬件。立即在html標籤下的div標籤的合法性
在某些情況下,我使用了一個快捷方式,以防止在支持和啓用JS的常規情況下一次性清除所有靜態HTML,包括將所有靜態HTML標記嵌套在標識的div
標記中被消滅。
後來我意識到,引起了我的lynx
編譯行爲改變:
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta name=viewport content="width=device-width">
<title>Title</title>
</head>
<body>
<div id="whatever">
<header>
<h1>First heading</h1>
</header>
<main>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
eiusmod tempor incididunt ut labore et dolore magna aliqua.
</p>
</main>
<footer>
<hr />
<p>
Footer.
</p>
</footer>
</div>
</body>
</html>
瀏覽的是(在http://driedleav.es/so_20170729/with_div_inside.html太)第一頭移動到左滿舵:
瀏覽本其他,在http://driedleav.es/so_20170729/without_div_inside.html也是,中心第一個標頭:
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta name=viewport content="width=device-width">
<title>Title</title>
</head>
<body>
<header>
<h1>First heading</h1>
</header>
<main>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
eiusmod tempor incididunt ut labore et dolore magna aliqua.
</p>
</main>
<footer>
<hr />
<p>
Footer.
</p>
</footer>
</body>
</html>
我無法在我的本地主機的WebKit軟件顯示它時,捕捉任何行爲差異。
爲了標準,兼容性和可訪問性,我應該放棄body
標籤中立即使用的div
標籤; JS代碼是以更大的開發成本和更大的下載成本爲代價的?
我的山貓編譯buggy?
我的WebKit編譯錯誤嗎?
請檢查[https://stackoverflow.com/q/45390048/1737973](https://stackoverflow.com/q/45390048/1737973)。 – uprego
如果您在自己的帖子中包含代碼的相關部分,那麼試圖幫助您的人可能會更容易。 – jcaron