The Css3--:target selector is called the target selector

Source: Internet
Author: User

:targetThe 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.