Hotels in Spain are a bit weird. There is a ridiculously confusing rating system which can be completely opaque to someone who hasn't been there before. I don't know what kind of place you would be interested in staying, so I'll just give you my own preferences.
When I travel overseas, I don't do anything in the hotel room except shower and sleep (well, and maybe something else involving a shower or a bed). I don't need a big room with a view or a hotel with a bar and restaurant. In Spain I usually stay in a "hostal", which is nothing like a "hostel". It's essentially a hotel with nothing but the basics. Often they're located on a single floor of a tall building - in fact, there may be seperate hostales on each floor. Last time I was in Madrid (2008 ), I believe my room cost me 35 - 40 euros, and it was clean and quiet and had its own bath (not all do) and air conditioning (you'll need it if you're going in summer). If that's the kind of place you're looking to stay, shoot me an e-mail - I may still have my list of hostales that I considered.
I strongly prefer to stay somewhere between the Puerta del Sol and the Plaza de Santa Ana. It's a very lively (str8 ) area at night, with lots of pubs hopping with locals and tourists, and it's very close to the Plaza Mayor (great place to hang out, and very historical too) and walking distance to the Museo del Prado (one of Europe's truly great museums, don't miss it). From that area it's also a pretty easy walk to the gay area (Chueca) if you're interested - although I'm not much impressed with it.
I also strongly recommend the Reina Sofia museum (a litle farther away) if you're into the Spanish surrealists (Dali, Miro).