[attr] selector

Not supported Explorer.

iCab and OmniWeb select all paragraphs.

Opera 7.10 and below does not support the custom ppk attribute.

Selects elements with a certain attribute or an attribute with a certain value.


p[class] {font-style: italic;}
p[ppk] {font-style: italic;}

The p[class] selector means "each element P with an attribute CLASS". There are two of them: the intro paragraph at the top of the page and the "smaller" test paragraph at the bottom of this page.

This paragraph has a ppk="true" attribute. It should be italic.

Attribute value


p[align=right] {font-style: italic;}
p[ppk=false] {font-weight: 600;}
p[class~=test] {text-decoration: underline;}

The p[align=right] selector means "each P that has an ALIGN attribute with value "right". The p[class~=test] selector means "each P that has a CLASS one of whose values is "test".

This paragraph has align="center". Nothing should happen.

This paragraph has align="right". It should be italic.

This paragraph has a ppk="false" attribute. It should be italic and bold.

This paragraph has a class="small test" attribute. It should be italic and underlined. (The small class is not styled, BTW)