通過指定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