How to target elements that only contains a space( ) with CSS?

Related searches

I'm having a table and there are some columns with the following code:

<td class="t-Report-cell" align="right" headers="KORTING_PERC">&nbsp;</td>

I would like to be able to target the TD's who are having the headers="KORTING_PERC" and contains only the html variant of a space.

I've tried the following:

td[headers="KORTING_PERC"]:contains("&nbsp;")
td[headers="KORTING_PERC"]:contains(" ")
td[headers="KORTING_PERC"]:not(:empty)

Using the following with a red background:

[headers="KORTING_PERC"]:not(:contains(" ")){
  background: red;
}

Results in:

div[headers='KORTING_PERC'][data-value='23'] {
   background-color: red;
}
     <div class="t-Report-cell" align="right" data-value="23" headers="KORTING_PERC">23</div>
     <div class="t-Report-cell" align="right" data-value="" headers="KORTING_PERC">23</div>

How whitespace is handled by HTML, CSS, and in the DOM, As others have stated, a space is not a valid character for an id attribute which allows space-separated values, elements can only have one single ID. JQuery: Why does ID in the selector be typed .target instead of #target in nth-child? The [attribute~="value"] selector is used to select elements with an attribute value containing a specified word. The following example selects all elements with a title attribute that contains a space-separated list of words, one of which is "flower":

There used to be a draft for :blank, but it did not made its way to browser implementations.

https://css-tricks.com/almanac/selectors/b/blank/

jQuery: How can I select a div whose @id contains a space?, The :empty pseudo selector will select elements that contain either nothing or only an HTML comment. div:empty { display: none; } Will Match� There may be zero or more tasks in a target. PropertyGroup: Contains a set of user-defined Property elements. Starting in the .NET Framework 3.5, a Target element may contain PropertyGroup elements. ItemGroup: Contains a set of user-defined Item elements. Starting in the .NET Framework 3.5, a Target element may contain ItemGroup elements.

Try this

$('td[headers="KORTING_PERC"]').each(function(){
   if($(this).text() == '&nbsp;' || $(this).text() == ''){
      $(this).css('background','red');
   }
});

:empty, It talks about pattern matching and how to select CSS elements. with quotes in order to select a CSS element that contains spaces. While html element can only have one id, the can have any number of class names. Let’s target the fields with the attribute name only when the value includes yourfield: input[name*="yourfield"] { /* Your custom CSS goes here */ } The code looks very similar to the previous example, however note we added the asterisk symbol (*) to target all the elements whose name value includes the string yourfield .

spaces in the class names, If "val" contains white space, it will never represent anything (since the words are The following assigns style only to H1 elements with class~="pastoral" : A. Specifying a target namespace The following XSD schema specifies a target namespace by using the xsd:targetNamespace attribute. The schema also sets the elementFormDefault and attributeFormDefault attribute values to "unqualified" (the default value for these attributes).

Selectors, Here the {target namespace} directly contains only the globally declared elements, which in turn contains its child elements in its symbol space. Every element contains the corresponding attributes in its symbol space; therefore, in the instance, only the globally declared elements and attributes must be qualified.

Note that the first selector, (“p:contains (favorite)”), includes a space before the target text. if it didn’t then clicking on the first button would select both lines, and replace them with the same text, since they both contain the string “favorite”.

Comments
  • 'Contains' doesn't exists in css.. Always try to code in english and don't give your variables dutch names.
  • Your table is populated via a script, probably? Then give the table cells a new class whenever they are filled with just a &nbsp;