跳到主要內容

巢狀 <style> 元素

每個元件只能有一個頂層的 <style> 標籤。

然而,可以在其他元素或邏輯區塊內巢狀使用 <style> 標籤。

在這種情況下,<style> 標籤會按原樣插入到 DOM 中;不會對 <style> 標籤進行範圍設定或處理。

<div>
	<style>
		/* this style tag will be inserted as-is */
		div {
			/* this will apply to all `<div>` elements in the DOM */
			color: red;
		}
	</style>
</div>

在 GitHub 上編輯此頁面

上一頁 下一頁