简体   繁体   中英

CSS Attribute selector not working on <li> element

I'm trying to target an <li> tag based on its title attribute but it is having no effect:

<style>      
[title~=Client PPT Presentation] {
display: none;
}
</style>
<li title="Client PPT Presentation">
</li>

Title is is a global attribute and I verified sytntax, so why isn't this working?

The ~= operator is used to select elements with an attribute value containing a specified word

Example:

[title~='Client'] {
  display: none;
}

If you want to check for a string value (not a single word) you have to use the *= operator which is used to select elements whose attribute value contains a specified value

[title*='Client PPT Presentation'] {
   display: none;
}

http://jsfiddle.net/

you should select it using [title="Client PPT Presentation"]

see http://jsfiddle.net/ngzck7bp/

Have you tried:

<style> 
li[title="Client PPT Presentation"] {
    display: none;
} 
</style>
<li title="Client PPT Presentation">
</li>

I believe this is what you need. You should honestly have just read this though.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM