Erick Boileau Erick Boileau - 21 days ago 5
CSS Question

SOLVED - CSS select tag without first-child

With CSS I want to select the li without description, without first-child = b , to apply a padding-letf on the li without title
HTML

<ul>
<li><b>title</b>description</li>
<li><b>title</b>description</li>
<li>description without title</li>
<li><b>title</b>description</li>
</ul>


something like

ul li:not[first-child=b]


PS: I cannot add a class to the different li, I cannot change the HTML

thank you

Answer

You cannot select list-items based on content till now. However if the goal is just to apply a padding-left on the li without title HTML, you can do it as follows:

ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

li {
  padding-left: 20px;
}

li > b:first-child {
  margin-left: -15px;
}
<ul>
  <li><b>title</b>description</li>
  <li><b>title</b>description</li>
  <li>description without title</li>
  <li><b>title</b>description</li>
</ul>