如何在 HTML 中建立文件部分?


使用 <div> 標記在文件中新增一個部分。HTML <div> 標記用於定義文件的部分。使用 div 標記,您可以將大塊 HTML 元素組合在一起並使用 CSS 設定它們的格式。

示例

您可以嘗試以下程式碼以建立部分 −

<!DOCTYPE html>
<html>
   <head>
      <title>HTML div Tag</title>
   <link rel = "stylesheet" href = "style2.css">
   </head>
   <body>
      <div id = "contentinfo">
         <p>Welcome to our website. We provide tutorials on various subjects.</p>
      </div>
   </body>
</html>

以下是 css 檔案 style2.css

#contentinfo p {
   line-height: 20px;
   margin: 30px;
   padding-bottom: 20px;
   text-align: justify;
   width: 140px;
   color: red;
}

更新於: 2020 年 3 月 3 日

9K+ 瀏覽

開啟您的 職業

完成課程即可獲得認證

立即開始
廣告
© . All rights reserved.