2017-07-29 73 views
0

我正在運行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太)第一頭移動到左滿舵:

enter image description here

瀏覽本其他,在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> 

enter image description here

我無法在我的本地主機的WebKit軟件顯示它時,捕捉任何行爲差異。

爲了標準,兼容性和可訪問性,我應該放棄body標籤中立即使用的div標籤; JS代碼是以更大的開發成本和更大的下載成本爲代價的?

我的山貓編譯buggy?

我的WebKit編譯錯誤嗎?

+0

請檢查[https://stackoverflow.com/q/45390048/1737973](https://stackoverflow.com/q/45390048/1737973)。 – uprego

+0

如果您在自己的帖子中包含代碼的相關部分,那麼試圖幫助您的人可能會更容易。 – jcaron

回答

0

爲了標準,兼容性和可訪問性,我應該放棄緊挨着body標籤使用的div標籤; JS代碼是以更大的開發成本和更大的下載成本爲代價的?

爲了標準的緣故,可能不是。爲了兼容性,如果想要支持特定版本的lynx,肯定是肯定的。

檢查這些,是相同的來源,但連續的多級標題作爲唯一的區別。

http://driedleav.es/so_20170729/with_div_inside_.html表現是這樣的:

enter image description here

http://driedleav.es/so_20170729/without_div_inside_.html表現是這樣的:

enter image description here

從瀏覽進一步的測試文檔,我看到的行爲一直是增加縮進水平,這似乎比似乎沒有做任何事情更安心。

我的Lynx編譯車?

因爲可能WebKit是100%兼容的,可能是的。

我的WebKit編譯buggy?

可能不是,因爲它是一個大型和成熟的項目使用的無數和眼球的bug的規律。

1

通過插入一個div,Lynx考慮創建一個隱含部分,它使該部分的標題成爲h1,而不再是網頁的標題。

您應該注意,用<main id="whatever">代替<div id="whatever">可得到預期結果。