0

everyone!

The general goal is that all li elements for which a property is not explicitly declared use the standard value.

I don't understand why the content property can't be reset:

ul {
 position: relative;
 list-style: none;
 margin-left: 0;
 padding-left: 1.2em;
}

li:before {
 content: unset;
}

ul > li:before {
 content: "A";
 position: absolute;
 left: 0;
}

ul > ul > li:before {
 content: "B";
 position: absolute;
 left: 0;
}
<ul>
 <li>Level 1 Item 1</li>
 <ul>
  <li>Level 2 Item 1</li>
  <ul>
   <li>Level 3 Item 1</li>
   <li>Level 3 Item 2</li>
   <li>Level 3 Item 3</li>
  </ul>
 </ul>
</ul>

Result:

Actual result: level 3 content is not unset and still shown

But shouldn't the result be like this:

Expected result: level 3 content is unset and hidden

How can I fix this so that the result is the same as in the last picture?

isNaN
  • 11
  • 5
  • @BoltClock thanks for support to insert image. I think maybe I should change the title of the question: How to cancel the inheritance of the "content property" without reassigning it for each
  • element?
  • – isNaN Apr 24 '21 at 05:32
  • Good call, you may make further edits to your own question. I'm currently writing an answer. – BoltClock Apr 24 '21 at 05:33
  • You should use the DOM inspector to see how the styles are applied to an element. – Barmar Apr 24 '21 at 05:34
  • **Your HTML is invalid to begin with. It needs to be fixed before anything else can be addressed.** `ul` can only have `li`, `script` and `template` children. That being said, `ul > ul` is not supposed to **ever** match an element, and if it does, that is most certainly a violation of the spec and could (and honestly **should**) stop working at any point in time. – connexo Apr 24 '21 at 07:03
  • @connexo That is, if I want to create an attachment, I need to declare the new level as "ul > li > ul"? – isNaN Apr 24 '21 at 11:12
  • If you need to nest `ul`s, the nested `ul`s need to reside in `li`. – connexo Apr 24 '21 at 13:49