CSS Learning notes--attribute Selector

Source: Internet
Author: User

This note is from----

[attribute] uses only property names, but no property values are determined
<! DOCTYPE html>{Height:30px;Border:1px solid #000;}p[Miaov],span[Miaov], #div1 [miaov],.div[Miaov]{background:Red;}</style>Miaov= "Leo" >111</p><!--Filter--<div > <span Miaov= "DP" >222</span><!--Filter--</div> <div id= "Div1" miaov= ZM >333</div><!--Filter-<div class= "div" miaov= "XM" >444</div><!--Filter </body>
[attribute=value] Specifies the property name and specifies the property value of the property
<! DOCTYPE html>{Height:30px;Border:1px solid #000;}p[Miaov=leo]{background:Red;}</style>Miaov= "Leo" >111</p><!--Filter--<p  Miaov= "DP" >222</p> <p Miaov= "ZM" >333</p> <p Miaov= "XM" >444</p ></body>
[attribute~=value] Specifies the property name and has a property value, which is a list of words separated by a space, where the word list contains a value word, and the "?" in front of the equal sign. I can't write .
 <! DOCTYPE html> {height : 30px ; border : 1px solid #000 ;} p[miaov~=old]{background:red;}  </style><!--filter-->  <p miaov= "ZM" >333</p> <p miaov= "xm old Young" >444</p><!--filter-->  </body> 
[attribute$=value] Specifies the name of the property and has a property value, and the value of the property is terminated with value
<! DOCTYPE html>{Height:30px;Border:1px solid #000;}p[Miaov$=m]{background: #CC0;}</style>Miaov= "Bleo old" >111</p> <p Miaov= " BDP ">222</p> <p Miaov=" Bzm ">333</p><!--filter --<p Miaov=" GXM ">444</p><!--filter --</body>
[attribute^=value] Specifies the property name and has a property value that is the value of the property that begins with value.
 <! DOCTYPE html> {height : 30px ; border : 1px solid #000 ;} p[miaov  ^=g]{background:pink;}  </style>miaov  = "Bleo old" >111</p> <p miaov  = "BDP" >111</p> <p Span style= "color: #800000;" >miaov  = "Bzm" >111</p> <p miaov  = "GXM" >111</p>< !--filter--></body>
[attribute*=value] Specifies the property name and has a property value that contains the value
<! DOCTYPE html>{height:30px;  Border:1px solid #000;} p[miaov*=d]{background: #C3C;} </style><!--filter-     <p miaov= "BDP" >222</p><!--filter--    <p miaov= "Bzm" >333</p>    <p miaov= "GXM" >444</p></body>
[attribute|=value] Specifies the property name, and the value of the property is either value or values beginning with "value-" (for example, ZH-CN)
<! DOCTYPE html>{Height:30px;Border:1px solid #000;}P[miaov|=b]{background:#C3C;}</style><!--filter and <p miaov= "Bleo" >222</p> <p miaov= "B-leo" >333</p><!--filter --<p miaov= "G-XM" > 444</p> <p miaov= "B" >555</p><!--filter --</body>

Example--Achieve the following effects

<! DOCTYPE html>{Height:30px;Line-height:30px;font-size:12px;Border:1px solid #000;}p a{background:URL (img/w.gif) no-repeat 3px Center;Padding-left:20px;Display:Block;}P A[href*=text]{Background-image:URL (img/text.gif);}P A[href*=pdf]{Background-image:URL (img/swf.gif);}P A[HREF*=EXL]{Background-image:URL (img/x.gif);}</style>

CSS Learning notes--attribute 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.