The AI reply above is not correct.
Officially the free upgrade time period to go from Windows 7 or 8 to Windows 10 or 11 ended in 2016, however after that, there was a loophole that allowed the free upgrade to continue.
In September 2023, Microsoft finally closed that loophole and since then, it is no longer possible to activate Windows 10 or 11 with a previous Windows 7 or 8 licence key, you will need to purchase a new Windows licence.