In the present work, we investigate the electronic and optical properties of few-layer MS2 (M = Mo, W) and their van der Waals heterostructure MoS2/WS2 using density functional theory. Our calculated results demonstrate that the energy gap of the MS2 depends tightly on the number of layers. Besides, maximum absorption of the few-layer MS2 occurs for energies in the range 10 eV to 15 eV and is also highly dependent on the number of layers. While the monolayers MS2 are direct semiconductors, the MoS2/WS2 heterostructure reveals an indirect band gap with a band gap smaller than that of the monolayers MoS2 and WS2. In the heterostructure, while the contribution of the W-sorbitals to the conduction band is outstanding, the Mo-s, Mo-p, and W-p orbitals contribute significantly to the valence band. The relocation of the orbital in the monolayers MS2 to form a heterostructure has brought many interesting properties that can be applied in the transistors based on MoS2/WS2 heterostructure.