CSS: How can I hide a class that does not have another class or identifier?

So how can I get a td that has only 1 class?

For instance:

<td class="ss_label ss_class">Hello</td> <td class="ss_label">World!</td> 

In this case, I want display:none second.

This works: $('[class="ss_label"]').hide(); but I do not want to use Javascript or any library like jQuery . Just pure CSS.

In a real life example, I want to hide, this is the sixth and seventh.

+4
source share
4 answers

You can use this attribute selector from jQuery in CSS:

 td[class="ss_label"] { display: none } 

This will correspond to the <td> element, the class attribute of which is exactly "ss_label" without any other additions to it. Works in all major browsers except IE6 (if you consider it a major browser).

+5
source

You can do:

 .ss_label { display: none } .ss_label.ss_class { display: table-cell } 

for this particular case.

As far as I know, there is no general solution.

+4
source
  <style type="text/css"> .ss_label { display:none; } .ss_label.ss_class { display:block; } </style> 

The last rule overrides the first

+1
source

Maybe you can use attribute selector (works in safari)

 <html> <head> <style> div.hide { color: green } div[class=hide] { display: none } </style> </head> <body> <div class="hide">Hide me</div> <div class="no hide">Don't hide me</div> </body> </html> 
+1
source

Source: https://habr.com/ru/post/1382958/


All Articles