edit: Note: As can be seen in the following discussion, the variant I presented in the following is only better at first glance. It is not recommended to use these and instead do the styling per row as mentioned before.
I did not want to repeat the card_mod style for every entity and adapted the code above having a single declaration for the entities card. If you have sensor entities the solution would be like this:
Yes, but how is that a disadvantage? The previous solution was to add styles for every single row. My solution only requires the specification for each type of row - if you only have one, as in my example, it is much easier this way. In addition, I define everything in a block at the end and not in between in the card configuration.
If you have a better solution that works generically for every type, then let me know
The longer DOM path you have - the less persistent & reliable your styles can be.
It is not about “how can I define a path to get to each type of row” - it is EASY with using “:first-child” etc.
So, I would suggest to use a per-row styling - it is less cumbersome with yaml-anchors, classes, decluttering-template etc - but it is more stable.
Hm ok, thank you very much for your explanation. I think this is “advanced programming” At the moment, I’m already happy if it works at all. At best, I even understand why.
But after reading your post again, I now understand your point of view and agree with you. With my variant, there is a greater chance that it will stop working at some point due to changes in the DOM. I’ll keep that in mind in the future.