Reputation: 1422
I'm trying to target an elements attribute that contains a colon: :
.someclass[xml:lang="da"]
HTML:
<span class="someclass" xml:lang="da">
Is this possible, does not work with above syntax?
Upvotes: 4
Views: 428
Reputation:
I do not recommend using the xml:lang
attribute. You should use the lang
attribute instead. The lang
attribute has the special behavior that it can be placed on any element at any level of the hierarchy, and then addressed via the :lang
pseudo-class, allowing you to define rules such as
:lang(de) {quotes: "«" "»"; }
and things will "just work".
Consult answers such as this one. Excerpt:
Note however that you may only use the
xml:lang
attribute if you either have an XML document or also define thelang
attribute, and in the latter case they must have the same value. This is becausexml:lang
is allowed only to ease transition of old XHTML documents.
Upvotes: 4
Reputation: 60543
CSS has special characters that cannot be applied in class names, so to use them, CSS escapes with a backslash (\
)
here is the list of the special characters:
!
, "
, #
, $
, %
, &
, '
, (
, )
, *
, +
, ,
, -
, .
, /
, :
, ;
, <
, =
, >
, ?
, @
, [
, \
, ]
, ^
, `
, {
, |
, }
, and ~
.someclass[xml\:lang="da"] {
background: red
}
<span class="someclass" xml:lang="da"> text</span>
Upvotes: 5