We propose a coalition-based approach to solve the task allocation problem of multiple robots with resource constraints. The resources required by task execution characterize the robots and tasks. Robots must form coalitions to accomplish the assigned tasks because individually, each robot may not complete the task independently due to resource limitation. We consider both online and offline assignment manners of the task allocation problem. For online assignment, a sequential coalition method is proposed to select efficiently the suitable robots to form coalitions for the assigned task. For offline assignment, a holistic coalition method is proposed for global optimization of all the assigned tasks. Both sequential and holistic coalition methods are compared with existing approaches. Numerous simulations and experiments performed on heterogeneous multiple mobile robots demonstrate the effectiveness of the proposed coalition-based task allocation methods. Note to Practitioners - Task allocation into a group of heterogeneous mobile robots for implementing multiple tasks is a challenge in multirobot applications. To find and organize the most suitable coalition for each task, we need to well organize the coalition for each task to maximize the robot group utility and optimize the task allocation solution. The sequential and holistic coalition methods presented in this paper provide both online and offline solutions for optimal multirobot task allocation. The advantage of the sequential coalition method lies in its efficiency in selecting best-fitted robots during coalition forming, and the advantage of the holistic coalition method lies in its effectiveness in finding the global optimal solution for all tasks. We illustrate the effectiveness of the proposed methods through numerous case studies with comparisons in this paper.