I wonder if the issue with a lack of response here isn't that the opening subject line is a bit confusing. I arrived here as the issue I have is that the PC / Windows 11 THINKS the printer is offline but it actually isn't! In fact, I spent the best part of my day trying all the HP solutions only to discover the reason I couldn't get the printer Online was because it actually always was online. It's just my PC thinks it's off.
What I found was the PC thinks the printer is offline every time the PC goes to 'sleep'. I've pinned the Settings menu to the PC task bar so I can open it up every time I go in and I see the Bluetooth & Devices menu and at the very top and it tells me the status of the printer. If it says Offline, nothing I do will get the PC to recognise it's online (which it is) but if I click the 'Run the Troubleshooter' button, the troubleshooter checks the spooler for a minute or so and the printer status switches to Idle (Online). Interestingly, the troubleshooter gives me a message saying 'No error found' but nevertheless this is the only thing I've found that 'fixes' the problem. Of course, I'm doing this EVERY time I want to print so it's hardly a fix...
This occurred for me when I installed a new router so I've got to the point where I think I'm going to have to find out how to completely deinstall the printer and install again from scratch.