Right-click the taskbar
Select Taskbar settings
Turn on Automatically hide the taskbar
On Windows 11, go to Settings > Personalization > Taskbar > Taskbar behaviors
Check Automatically hide the taskbar
On Windows 10, go to Settings > Personalization > Taskbar
Turn on Automatically hide the taskbar in desktop mode
Turn on Automatically hide the taskbar in tablet mode if needed
Close the settings window
