html 自定義標簽使用實現方法


 

通過指定html命名空間的名字來定義自定義標簽;默認的一些標簽p div等都在html默認的命名空間下。而自定義的標簽可以放在自定義的命名空間下,可通過xmlns:命名空間名 來指定,而自定義標簽需要帶命名空間名,而在設置樣式的時候使用 " 命名空間名\:標簽名  "
  

 

<!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd>
<html xmlns:ownhtml>
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
        ownhtml\:customdiv{
            font-size: .36rem;
            font-weight: bold;
            color:red;
        }
        p{
            color: green;
        }
    </style>
</head>
 <body>
  <!--
  通過指定html命名空間的名字來定義自定義標簽;默認的一些標簽p div等都在html默認的命名空間下。而自定義的標簽可以放在自定義的命名空間下,可通過xmlns:命名空間名 來指定,而自定義標簽需要帶命名空間名,而在設置樣式的時候使用 " 命名空間名\:標簽名  "
  -->
    <ownhtml:customdiv class="custom">this is a custom element!</ownhtml:customdiv>

    <p>this is normal text</p>
</body>
</html>

 

 

 參考: http://www.jb51.net/web/18067.html


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM