国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > HTML5 > 正文

HTML5的結構和語義(2):結構

2024-09-05 07:11:26
字體:
來源:轉載
供稿:網友

  由于缺少結構,即使是形式良好的 html 頁面也比較難以處理。必須分析標題的級別,才能看出各個部分的劃分方式。邊欄、頁腳、頁眉、導航條、主內容區和各篇文章都由通用的 div 元素來表示。html 5 添加了一些新元素,專門用來標識這些常見的結構:

 · section:這可以是書中的一章或一節,實際上可以是在 html 4 中有自己的標題的任何東西
 · header:頁面上顯示的頁眉;與 head 元素不一樣
 · footer:頁腳;可以顯示電子郵件中的簽名
 · nav:指向其他頁面的一組鏈接
 · article:blog、雜志、文章匯編等中的一篇文章

  我們來考慮一個典型的 blog 主頁,它的頂部有頁眉,底部有頁腳,還有幾篇文章、一個導航區和一個邊欄,見代碼1 典型的 blog 頁面

<html>
  <head>
    <title>mokka mit schlag </title>
 </head>
<body>
<div id="page">
  <div id="header">
    <h1><a href="http://www.elharo.com/blog">mokka mit schlag</a></h1>
  </div>
  <div id="container">
    <div id="center" class="column">              
      <div class="post" id="post-1000572">
        <h2><a href=
      "/blog/birding/2007/04/23/spring-comes-and-goes-in-sussex-county/">
      spring comes (and goes) in sussex county</a></h2>
        <div class="entry">
          <p>yesterday i joined the brooklyn bird club for our
          annual trip to western new jersey, specifically hyper
          humus, a relatively recently discovered hot spot. it
          started out as a nice winter morning when we arrived
          at the site at 7:30 a.m., progressed to spring around
          10:00 a.m., and reached early summer by 10:15. </p>
        </div>
      </div>
      <div class="post" id="post-1000571">
        <h2><a href=
          "/blog/birding/2007/04/23/but-does-it-count-for-your-life-list/">
           but does it count for your life list?</a></h2>
        <div class="entry">
          <p>seems you can now go <a
          href="http://www.wired.com/science/discoveries/news/
          2007/04/cone_sf">bird watching via the internet</a>. i
          haven't been able to test it out yet (20 user
          limit apparently) but this is certainly cool.
          personally, i can't imagine it replacing
          actually being out in the field by any small amount.
          on the other hand, i've always found it quite
          sad to meet senior birders who are no longer able to
          hold binoculars steady or get to the park. i can
          imagine this might be of some interest to them. at
          least one elderly birder did a big year on tv, after
          he could no longer get out so much. this certainly
          tops that.</p>
        </div>
      </div>
      </div>
    <div class="navigation">
      <div class="alignleft">
         <a href="/blog/page/2/">« _fcksavedurl=""/blog/page/2/">«" previous entries</a>
       </div>
      <div class="alignright"></div>
    </div>
  </div>
  <div id="right" class="column">
    <ul id="sidebar">
      <li><h2>info</h2>
      <ul>
        <li><a href="/blog/comment-policy/">comment policy</a></li>
        <li><a href="/blog/todo-list/">todo list</a></li>
      </ul></li>
      <li><h2>archives</h2>
        <ul>
          <li><a href='/blog/2007/04/'>april 2007</a></li>
          <li><a href='/blog/2007/03/'>march 2007</a></li>
          <li><a href='/blog/2007/02/'>february 2007</a></li>
          <li><a href='/blog/2007/01/'>january 2007</a></li>
        </ul>
      </li>
    </ul>
  </div>
  <div id="footer">
    <p>copyright 2007 elliotte rusty harold</p>
  </div>
</div>
</body>
</html>

  即使有正確的縮進,這些嵌套的 div 仍然讓人覺得非?;靵y。在 html 5 中,可以將這些元素替換為語義性的元素,見代碼2 用 html5編寫的典型blog頁面

<html>
 <head>
    <title>mokka mit schlag </title>
 </head>
<body>
  <header>
    <h1><a href="http://www.elharo.com/blog">mokka mit schlag</a></h1>
  </header>
  <section>              
      <article>
        <h2><a href=
        "/blog/birding/2007/04/23/spring-comes-and-goes-in-sussex-county/">
         spring comes (and goes) in sussex county</a></h2>
        <p>yesterday i joined the brooklyn bird club for our
        annual trip to western new jersey, specifically hyper
        humus, a relatively recently discovered hot spot. it
        started out as a nice winter morning when we arrived at
        the site at 7:30 a.m., progressed to spring around 10:00
        a.m., and reached early summer by 10:15. </p>
      </article>
      <article>
        <h2><a href=
          "/blog/birding/2007/04/23/but-does-it-count-for-your-life-list/">
          but does it count for your life list?</a></h2>
          <p>seems you can now go <a
          href="http://www.wired.com/science/discoveries/news/
          2007/04/cone_sf">bird watching via the internet</a>. i
          haven't been able to test it out yet (20 user
          limit apparently) but this is certainly cool.
          personally, i can't imagine it replacing
          actually being out in the field by any small amount.
          on the other hand, i've always found it quite
          sad to meet senior birders who are no longer able to
          hold binoculars steady or get to the park. i can
          imagine this might be of some interest to them. at
          least one elderly birder did a big year on tv, after
          he could no longer get out so much. this certainly
          tops that.</p>
      </article>   
    <nav>
      <a href="/blog/page/2/">« _fcksavedurl=""/blog/page/2/">«" previous entries</a>
    </nav>
  </section>
  <nav>
    <ul>
      <li><h2>info</h2>
      <ul>
        <li><a href="/blog/comment-policy/">comment policy</a></li>
        <li><a href="/blog/todo-list/">todo list</a></li>
      </ul></li>
      <li><h2>archives</h2>
        <ul>
          <li><a href='/blog/2007/04/'>april 2007</a></li>
          <li><a href='/blog/2007/03/'>march 2007</a></li>
          <li><a href='/blog/2007/02/'>february 2007</a></li>
          <li><a href='/blog/2007/01/'>january 2007</a></li>
        </ul>
      </li>
    </ul>
  </nav>
  <footer>
    <p>copyright 2007 elliotte rusty harold</p>
  </footer>
</body>
</html>

  現在不再需要 div 了。不再需要自己設置 class 屬性,從標準的元素名就可以推斷出各個部分的意義。這對于音頻瀏覽器、手機瀏覽器和其他非標準瀏覽器尤其重要。
  
 ?。ùm)

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 夏河县| 屯留县| 饶阳县| 东港市| 读书| 河池市| 望都县| 大余县| 固安县| 松阳县| 德江县| 新丰县| 澎湖县| 东辽县| 盘山县| 礼泉县| 广灵县| 宁安市| 竹北市| 南岸区| 巢湖市| 临漳县| 东丰县| 沁阳市| 伊通| 鸡泽县| 宣武区| 景德镇市| 绥江县| 武隆县| 普陀区| 枣强县| 鄂托克前旗| 东兴市| 固原市| 伽师县| 本溪| 启东市| 福清市| 叙永县| 英山县|