Solved

Is it possible to make these CSS attribute selectors case-sensitive?

Posted on 2014-03-04
7
372 Views
Last Modified: 2014-03-04
I've got this bit of HTML, adapted from an example on w3schools.com:

<!DOCTYPE html>
<html>
<head>
<title>List Test</title>
<style type="text/css">

ol[type="a"] li
{
   color: red;
}

ol[type="A"] li
{
   color: green;
}

</style>
</head>
<body>

<ol type="a">
  <li>Coffee</li>
  <li>Tea</li>
  <li>Milk</li>
</ol>

<ol type="A">
  <li>Coffee</li>
  <li>Tea</li>
  <li>Milk</li>
</ol>
 
</body>
</html>

Open in new window


Firefox and Chrome render both lists in green, because the type attribute is not case-sensitive in CSS attribute selectors. Is there a way around this, short of adding class names to all my ol elements?

(I ask because we have a less-specific rule on li elements on list-style-type and I'm trying to restore the expected behavior. The obvious solution is to make that less-specific rule more specific, but I'd like to avoid the ton of regression testing that would require.)
0
Comment
Question by:CPColin
  • 4
  • 2
7 Comments
 
LVL 58

Expert Comment

by:Gary
ID: 39903983
CSS is completely case insensitive so the only way around it is to use a unique identifier.
0
 
LVL 14

Author Comment

by:CPColin
ID: 39904000
When it comes to ID's, class names, and attributes that refer to ID's, CSS is definitely case-sensitive. I was hoping that a style rule that referred to an attribute that is case-sensitive in HTML5 would join those other case-sensitive parts and be case-sensitive itself.
0
 
LVL 34

Accepted Solution

by:
Paul MacDonald earned 500 total points
ID: 39904017
Seems to me you could use javascript to do something like this.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 14

Author Comment

by:CPColin
ID: 39904052
Using JavaScript for this feels like an unnecessary layer of complexity when the browsers' default behavior should be sufficient. It sounds like the only real solution is to make our rule on li elements more specific.
0
 
LVL 58

Expert Comment

by:Gary
ID: 39904114
But we are not talking about ID and CLASS, your question is about TYPE and it is not case sensitive.
TYPE isn't a default CSS selector like ID and CLASS
Why not just add a class to the elements?
0
 
LVL 14

Author Comment

by:CPColin
ID: 39904123
You said, "CSS is completely case insensitive." I was merely correcting that statement and clarifying my question.
0
 
LVL 14

Author Closing Comment

by:CPColin
ID: 39904127
My question was "Is there a way to make this case-sensitive?" and the only answer is, "Use JavaScript."

I'm going to keep looking, but that's the correct answer, based on how I phrased my question. Thanks!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
In this tutorial viewers will learn how to style a decorative dropcap for the first letter in a paragraph using CSS. In CSS, create a new paragraph class by typing "p.fancy": Then, to style only the first letter of the first sentence, include the ps…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

919 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now