Home > Web Front-end > HTML Tutorial > The difference between [attribute~=value] and [attribute*=value] in css attribute selector_html/css_WEB-ITnose

The difference between [attribute~=value] and [attribute*=value] in css attribute selector_html/css_WEB-ITnose

WBOY
Release: 2016-06-24 11:44:09
Original
1489 people have browsed it


[attribute]    用于选取带有指定属性的元素。    [attribute=value]    用于选取带有指定属性和值的元素。    [attribute~=value]    用于选取属性值中包含指定词汇的元素。    [attribute|=value]    用于选取带有以指定值开头的属性值的元素,该值必须是整个单词。    [attribute^=value]    匹配属性值以指定值开头的每个元素。    [attribute$=value]    匹配属性值以指定值结尾的每个元素。    [attribute*=value]    匹配属性值中包含指定值的每个元素。    
Copy after login



下面的例子为包含指定值的 title 属性的所有元素设置样式。适用于由空格分隔的属性值:[title~=hello] { color:red; }下面的例子为带有包含指定值的 lang 属性的所有元素设置样式。适用于由连字符分隔的属性值:[lang|=en] { color:red; }
Copy after login


~= where value must be one Independent words, such as [title~=test], test a can be selected, testa cannot be selected.
*=The value only needs to be a substring of the value. For example, test-a, test a and testa can all be selected.
|= has the same characteristics as ~=, ^= has the same characteristics as *=. Therefore, it is usually better to use ^= and *=.

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template