Share via


:target

套用一或多個樣式至參照統一資源識別元 (URI) 的目標元素。

語法

:target { sRules }

可能的值

sRules

指定一或多個階層式樣式表 (CSS) 屬性/值組的值。

備註

:target 虛擬類別會選取參照 URI 的目標元素。片段識別碼可用來識別頁面內的位置,並使用數字符號後接錨點識別碼的格式 — 例如 http://www.example.com/mypage.html#section_3

範例

下列程式碼會選取 important 類別的 div ,作為參照 URI 的目標元素。如果文件的 URI 沒有片段識別碼,表示它沒有目標元素。

div.important:target

標準資訊

您可以在 CSS Selectors Level 3 (CSS 選取器層級 3) Gg721771.xtlink_newWindow(zh-tw,Expression.40).png 找到此虛擬元素的定義。

適用範圍

a , abbr , acronym , address , b , big , blockquote , body , caption , center , cite , code , col , colgroup , dd , dfn , dir , div , dl , dt , em , form , hn , html , i , img , input , input type=button , input type=checkbox , input type=file , input type=hidden , input type=image , input type=password , input type=radio , input type=reset , input type=submit , input type=text , kbd , label , legend , li , listing , marquee , menu , ol , p , plaintext , pre , s , samp , select , small , span , strike , strong , sub , sup , table , tbody , td , textarea , tfoot , th , thead , tr , tt , u , ul , var , xmp

另請參閱

概念

虛擬類別
虛擬類別與虛擬元素