0

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

thank you

Jongware
  • 22,200
  • 8
  • 54
  • 100
Erick Boileau
  • 478
  • 4
  • 14

3 Answers3

1

this is impossible with css due to the way browser is matching selectors - you cannot select element by something that is inside of it... however, it might be available in the future

pwolaq
  • 6,343
  • 19
  • 45
1

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>
pwolaq
  • 6,343
  • 19
  • 45
Mohammad Usman
  • 37,952
  • 20
  • 92
  • 95
1

A workaround, if it helps anyway:

ul{
    padding-left:5px;
}
li > b{
    margin-left:-5px;
}
Jones Joseph
  • 4,703
  • 3
  • 22
  • 40