Practising the CSS2 attribute selector
This page shows some examples about the CSS attribute selector.
Let's consider following CSS selectors: the first lines define the properties for the elements
having an attribute named my_attribute
. The last lines exploits the properties of the
attribute selector to implement an inheritance effect for CSS definitions.
See below for the result when applying these CSS definitions.
Results
This paragraph has an attribute named my_attribute
(notice: it is a custom attribute!)
This paragraph has an attribute named my_attribute
with value second
This paragraph has an attribute named my_attribute
with value the-third
(hyphen separated)
This paragraph has an attribute named my_attribute
with value last row
(whole word).
It contains also this sentence (enclosed by span
tags),
and this single word
This paragraph has not attributes at all
This paragraph has an attribute named my_attribute
with value second
This paragraph has class child-1
(hence it extends the child
class)
This paragraph has class child-2
(hence it extends the child
class)