With 1.7 milloner inhabitants, Hamburg is a big city, but it still not feels like that.
If you like to walk one to two kilometers, most attractions are within walking distance.
Otherwise, of course, public transport is well constructed and easy to use.
Best is to buy a day pass and go how much you want with the “S-bahn” “U-bahn” and buses.
Many hotels offer a free pass during your stay with them.
For tickets, prices and more information, see the lokal traffic site at hvv.de