CSS :not on items which do not contain any id

I have the following markup and I know that I can apply style on li which do not contain specific id as the example shows, but how do I simplify the example below to be like if not id than apply another style?

ul > li:not(#_1):not(#_3) 
<ul>
<li id="_1"></li>
<li></li> 
<li id="_3"></li>
<li></li>
<li id="_5"></li>  
</ul>

Answers


You can do it using the negation along with the attribute selector.

The selector li:not([id]) would select only li elements which doesn't have an id attribute.

ul > li:not([id]) {
  background: red;
}
<ul>
  <li id="_1"></li> <!-- will not be selected -->
  <li></li>         <!-- will be selected -->
  <li id="_3"></li> <!-- will not be selected -->
  <li></li>         <!-- will be selected -->
  <li id="_5"></li> <!-- will not be selected -->
  <li id=""></li>   <!-- will not be selected -->
</ul>

Need Your Help

GROUP_CONCAT equivalent in Django

mysql django group-concat

Say I have the following table called fruits:

SSH to RaspberryPi which is connected via iPhone Hotspot

iphone ssh wifi raspberry-pi2 personal-hotspot

I have a RaspberryPi which is configured to automatically connect to my iPhone's wifi hotspot. I need to take the RaspberryPi to various locations for testing, and I often need to leave it at a loc...