Is it possible to select all elements with an attribute value greater than a certain number?

Blackbam

I wonder if the following is possible with CSS:

HTML-Code:

<span class="funny-elem" data-mystate="127">Hello World</span>
<span class="funny-elem" data-mystate="69">Hello Bird</span>
<span class="funny-elem" data-mystate="1337">Hello Nerd</span>
<span class="funny-elem" data-mystate="14">Hello What</span>
<span class="funny-elem" data-mystate="0">Hello Else</span>
...

CSS-Code:

.funny-elem[data-mystate=">50"] {
    color:#0f0;
}

.funny-elem[data-mystate="<50"] {
    color:#f00;
}

The above CSS code will not work of course as the "greater than" and "lesser than" sign are interpreted as attribute value here.

However do you know a way to select all elements with an numerical attribute value greater than or lesser than a certain number?

LcSalazar

No, there's no way in pure CSS.

Possible attribute selectors are:

  • [att]
  • [att=val]
  • [att~=val]
  • [att|=val]

And W3's docs on Attribute Selector adds:

Attribute values must be CSS identifiers or strings. [CSS21] The case-sensitivity of attribute names and values in selectors depends on the document language.

So, they're not numeric. There's no way to use any numeric comparision.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Is it possible to select all elements with an attribute value greater than a certain number?

From Dev

subset data.table keeping only elements greater than certain value applied to all columns

From Dev

Select all columns greater than some value

From Dev

Select all columns greater than some value

From Dev

Microsoft Excel how to select all cells that meet certain condition (i.e greater than a value)

From Dev

Is it possible to Multiply elements in the array if the elements value is greater than 10?

From Java

Check if all values in list are greater than a certain number

From Dev

Change output of slider if value is greater than a certain number

From Dev

Select records having a time interval greater than a certain value in Teradata

From Dev

Java Not greater than certain value

From Java

Replace all elements of Python NumPy Array that are greater than some value

From Dev

Print Line if output is greater than a certain number

From Dev

Find all elements that have a certain data attribute (regardless of value)

From Dev

Getting a list of lists for all elements in list of lists greater than a certain threshold

From Dev

Scala get all elements in a list less than a certain value

From Dev

How to take a median of all the values greater than a certain number if the data is stored in a numpy array?

From Dev

How to move all files matching a certain name to a new folder if the number of matching files is greater than 10?

From Dev

Jquery if value is greater than a certain length

From Java

What is causing it, when the value is greater than a certain number of digits, the result will be different?

From Dev

Select array elements that are greater than 5% of a sum

From Dev

Remove all divs where child element contains text greater than certain value

From Dev

Remove elements in a vector that are greater than value

From Dev

jQuery - select all elements with attribute name (not value) beginning with...?

From Dev

Select all the elements within an element having an attribute set to a specific value

From Dev

mysql value greater than percent of number of values

From Dev

matplotlib boxplot to plot < > greater than and less than a certain value

From Dev

Select where no value is greater than X

From Dev

How to scan a pandas dataframe for all values greater than something and returns row and column number corresponding to that value?

From Dev

How to scan a pandas dataframe for all values greater than something and returns row and column number corresponding to that value?

Related Related

  1. 1

    Is it possible to select all elements with an attribute value greater than a certain number?

  2. 2

    subset data.table keeping only elements greater than certain value applied to all columns

  3. 3

    Select all columns greater than some value

  4. 4

    Select all columns greater than some value

  5. 5

    Microsoft Excel how to select all cells that meet certain condition (i.e greater than a value)

  6. 6

    Is it possible to Multiply elements in the array if the elements value is greater than 10?

  7. 7

    Check if all values in list are greater than a certain number

  8. 8

    Change output of slider if value is greater than a certain number

  9. 9

    Select records having a time interval greater than a certain value in Teradata

  10. 10

    Java Not greater than certain value

  11. 11

    Replace all elements of Python NumPy Array that are greater than some value

  12. 12

    Print Line if output is greater than a certain number

  13. 13

    Find all elements that have a certain data attribute (regardless of value)

  14. 14

    Getting a list of lists for all elements in list of lists greater than a certain threshold

  15. 15

    Scala get all elements in a list less than a certain value

  16. 16

    How to take a median of all the values greater than a certain number if the data is stored in a numpy array?

  17. 17

    How to move all files matching a certain name to a new folder if the number of matching files is greater than 10?

  18. 18

    Jquery if value is greater than a certain length

  19. 19

    What is causing it, when the value is greater than a certain number of digits, the result will be different?

  20. 20

    Select array elements that are greater than 5% of a sum

  21. 21

    Remove all divs where child element contains text greater than certain value

  22. 22

    Remove elements in a vector that are greater than value

  23. 23

    jQuery - select all elements with attribute name (not value) beginning with...?

  24. 24

    Select all the elements within an element having an attribute set to a specific value

  25. 25

    mysql value greater than percent of number of values

  26. 26

    matplotlib boxplot to plot < > greater than and less than a certain value

  27. 27

    Select where no value is greater than X

  28. 28

    How to scan a pandas dataframe for all values greater than something and returns row and column number corresponding to that value?

  29. 29

    How to scan a pandas dataframe for all values greater than something and returns row and column number corresponding to that value?

HotTag

Archive