I'm trying to style an OL based on its type attribute. The list-style attributes for all ULs and OLs have been wiped out previously by another CSS stylesheet which I cannot really modify, and I need to re-style the list-style, taking the type into account, i.e. if the OL should use Roman characters or alphanumerics, etc.
That's easy, I thought; I'll just use the attribute selector to target the OLs based on the value of the type attribute. The attribute selector is case sensitive, so this should be easy, right?
Wrong - at least when you try to use the standard "type" attribute.
Here's an example (which works):
/* Remove default list style */
ul, ol { list-style:none; }
/* This works, using a non-standard foo attribute. The selector is case sensitive, so I can target 'i' and 'I' separately */
ol[foo='i'] {
list-style-type:lower-roman;
}
ol[foo='I'] {
list-style-type:upper-roman;
}
<ol foo="i">
<li>Styled with lower case roman</li>
<li>Styled with lower case roman</li>
</ol>
<ol foo="I">
<li>Styled with uppercase roman</li>
<li>Styled with uppercase roman</li>
</ol>
Now, replace foo
with type
and try again:
/* Remove default list style */
ul, ol { list-style:none; }
/* Trying to use the standard type attribute, the selector is no longer case sensitive, so I cannot style 'i' and 'I' individually .... */
ol[type='i'] {
list-style-type:lower-roman;
}
ol[type='I'] {
list-style-type:upper-roman;
}
<ol type="i">
<li>Should be lower-case roman</li>
<li>Should be lower-case roman</li>
</ol>
<ol type="I">
<li>Should be upper-case roman</li>
<li>Should be upper-case roman</li>
</ol>
Now it's like the selector is no longer case-sensitive and both lists are affected, and both use upper-case Romans.
I've not been able to find any information whether this is the correct behaviour or not, that is, when using a known attribute such as 'type' v.s using non-standard attribute like 'foo'. The fact that this happens both in Chrome and Firefox makes be believe that it's not a bug.
Any ideas?
Here is a CodePen to mess with: https://codepen.io/haukurhaf/pen/NOQYOz
type
attribute into adata-type
or something (either via JavaScript that runs over the content, or via server-side pre-processing of the data), and then have your CSS rules target that one instead … – Tonsure