CSS property selector

CSS Attribute Selector

HTML element style with specific attributes

HTML element style with specific attributes is not just class and id.

Note: IE7 and IE8 need to declare!DOCTYPE to support attribute selectors! IE6 and lower versions do not support attribute selectors.


Attribute Selector

The following example turns all elements containing the title blue :

     

我没有变

Hello world

PHP中文网

PHP.cn

Hello!

Run the program to try it


Attribute and value selector

The following example changes the title Border style of title='php.cn' element:

    php中文网(php.cn)  

将适用:


php中文网

将不适用:

Hi!

php中文网

Run the program to try it


Attribute and value selector - multi-value

The following is an example of an element style that contains a title attribute with a specified value. Use (~) to separate the attribute and value:

    php中文网(php.cn)  

将适用:

Hello world

Hello CSS students!


将不适用:

Hi CSS students!

Run the program to try it


The following is an example of an element style that contains a lang attribute with a specified value. Use (|) to separate the attribute and value:

    php中文网(php.cn)  

将适用:

Hello!

Hi!

Ello!


将不适用:

Hi!

Hei!

Run the program to try it


Form style

Attribute selector style does not need to use the form of class or id:

    php中文网(php.cn)  
姓名: 密码:

Run the program to try it



Continuing Learning
||
php中文网(php.cn)
姓名: 密码:
submit Reset Code
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!