<編寫高品質代碼--web前端開發修鍊之道>之html總結

來源:互聯網
上載者:User

標籤:

最近在看一本書,覺得講得特別精闢,把一些重要的地方記錄下來
   使用語義化的標籤
   (1)好處:能夠很好地自我解釋,方便搜尋引擎理解網頁的機構,抓取重要內容,去樣式後也會根據瀏覽器的預設樣式很好地組織網頁內容,具有很好的可讀性,從而實現對特殊終端的相容
   (2)常見模組:
   demo 1: 常見的標籤
   <h1>title</h1>
   <a href="#">更多</a>
   <p>段落</p>
   
   
   demo 2:表單
   <form action="" method="post">
      <fieldset>
           <legend>form title</legend>
           <label for="nameid">姓名</label>
           <input type="text"  id="nameid"/>
           <label for="password">密碼</label>
           <input type="password"/>
           <input type="submit" value="登陸"/>
     </fieldset>
  </form>
 
  demo 3: 表格
  <table>
     <caption>表單html</caption>
     <thead>
        <tr>
          <th>表頭1</th>
          <th>表頭2</th>
          <th>表頭3</th>
        </tr>
    </thead>
    <tbody>
       <tr>
          <td>儲存格1</td>
          <td>儲存格2</td>
          <td>儲存格3</td>
       </tr>
    </tbody>
    </table>
    注意demo2中的label中的for內容應該和input中的id保持一致
    幾點建議:
    (1)儘可能少地使用無語義標籤div或者span
    (2)在語義不明顯,既可以使用p也可以使用div的情況下,最好使用p,因為p有上下行邊距,去掉樣式之後可讀性更好,對相容特殊終端有利
    (3)不用使用純樣式標籤,比如b,font或者u之類的標籤,
        
         

<編寫高品質代碼--web前端開發修鍊之道>之html總結

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.