How to align some nav items to the left and some to the right?

How can I align some nav items to the left and some to the far right of the nav bar?

I have already set the nav width to 100%, I have tried setting margin-left to auto for the right/last item, I have tried wrapping them in divs (which resulted in other layout issues), …

All the items are wrapped in a <li> tag, which I cannot reach by setting CSS on the items.

Any suggestions?

This hack works for me to align one item to the right of the nav bar:

Add an attribute to the nav item with name parent and value fw, then add this CSS:

li:has(a[parent="fw"]) { margin-left: auto; }

I was hoping there would be a simpler way, but at least this one works (for now).