Click the Apple menu
Select System Settings
Click Desktop & Dock
Turn on Automatically hide and show the Dock
On older macOS versions, open System Preferences
Click Dock & Menu Bar
Check Automatically hide and show the Dock
Use Option-Command-D to toggle the Dock visibility on some macOS versions
