如何在HTML5中創建有效的自定義標籤/元素?HTML5有效的自定義標籤/元素
實施例1:
<customTag attr1="val" attr2="val">
</customTag>
實施例2:
<my:customTag attr1="val" attr2="val">
</my:customTag>
<!-- attention to the COLON separator -->
感謝。
如何在HTML5中創建有效的自定義標籤/元素?HTML5有效的自定義標籤/元素
實施例1:
<customTag attr1="val" attr2="val">
</customTag>
實施例2:
<my:customTag attr1="val" attr2="val">
</my:customTag>
<!-- attention to the COLON separator -->
感謝。
啊,但允許自定義元素。很尷尬https://dvcs.w3.org/hg/webcomponents/raw-file/tip/explainer/index.html#custom-element-section – albert 2013-03-13 08:36:09
@albert它不允許你把'
該死的...很好。 xtags確實讓你,但沒有把它放到web組件api中......可能是因爲你首次發布的答案中的原因。我的錯。 – albert 2013-03-13 09:27:37
我不認爲你需要冒號。在他們的例子中,xtags(mozilla lib)或w3c spec都沒有顯示它們。 xtags:http://x-tags.org/ w3c:https://dvcs.w3.org/hg/webcomponents/raw-file/tip/explainer/index.html#decorators-example
自定義元素是一個真正的W3 DOM API,很快就會驗證 - 老實說,在這種情況下不需要擔心驗證,這是無關緊要的。自定義元素的規範正在Firefox和Chrome中積極實施 - 目前正在進行夜間構建。
在標籤名稱中不需要冒號,這不是XML名稱空間。然而,標籤須在自定義的元素名稱的地方有一個破折號,每規範:https://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/custom/index.html
的W3C Custom Element spec說,你可以自定義標籤,唯一的要求是,它包含了連字符,不冒號。
根據我的經驗,這是第一個例子。 – 2013-03-13 07:48:25