http://www.andalucia.com/travel/ferry/home.htm
If you don't want to do it independently, there are several companies who offer day trips to Tangier with an interesting guided tour of the city and lunch, and trips can be booked at all the local tourist information offices. This is one we booked direct and which I would recommend. It goes from Tarifa and the coach picks up at various places along the Costa del Sol. Europa21 Travel Service 0034 952389807, siesta hours, or 0034 667413359, 24 hours. They speak English, so telephoning them is not a problem. Like all organised tours, you are herded to a degree, but we found it worthwhile.