The top of my foot close to my ankle is swollen and painful. The pain and swelling spreads horizontally across the entire width of the top of my foot.?

Many possibilities. Injury, tendon or liagment strain/sprain, gout, infection are some. See podiatrist.
Read below. If you are a male, this could be gout and you should see your doctor asap. This could also be caused by trauma to the ankle from exercise or soccer. This may also be a cyst on the top of the ankle. To be certain, i would visit my podiatrist. Good luck.