:target
The selector is called the target selector, which is used to match the target element of a marker for a document (page) URL. Let's start with the last example and then do the analysis.
Sample Show
Click the link to show the hidden paragraphs.
HTML code:
CSS code:
. menusection{ display:none;}:target{/* here: Target refers to the id= "brand" div Object */ Display:block;}
Demo Result:
Analysis:
1. Specifically, the marker in the URL of the triggering element usually contains a # number followed by a marker name, in the code above:#brand
2.: Target is used to match the element with the ID "brand" (id= "brand" Element), the above code is the DIV element.
Multiple URLs (multiple target) processing:
As the example above, #brand与后面的id = "Brand" is the corresponding, when the same page has a lot of URLs when you can take a different name, as long as the # number after the name and id= "" in the name corresponding to it.
As in the following example:
HTML code:
CSS code:
#brand: target { background:orange; Color: #fff;} #jake: target { background:blue; Color: #fff;} #aron: target { background:red; Color: #fff;}
The above code can set a different style for each target object.
My understanding:
Is by: Target this selector allows the href in the a tag to control the element corresponding to the ID in the href name.
The Css3--:target selector is called the target selector