We present a study of the relation between dark matter halo mass and the baryonic content of host galaxies, quantified via luminosity and stellar mass. Our investigation uses 154 deg2 of Canada-France-Hawaii Telescope Lensing Survey (CFHTLenS) lensing and photometric data, obtained from the CFHT Legacy Survey. We employ a galaxy-galaxy lensing halo model which allows us to constrain the halo mass and the satellite fraction. Our analysis is limited to lenses at redshifts between 0.2 and 0.4. We express the relationship between halo mass and baryonic observable as a power law. For the luminosity-halo mass relation we find a slope of 1.32+/-0.06 and a normalisation of 1.19+0.06-0.07x10^13 h70^-1 Msun for red galaxies, while for blue galaxies the best-fit slope is 1.09+0.20-0.13 and the normalisation is 0.18+0.04-0.05x10^13 h70^-1 Msun. Similarly, we find a best-fit slope of 1.36+0.06-0.07 and a normalisation of 1.43+0.11-0.08x10^13 h70^-1 Msun for the stellar mass-halo mass relation of red galaxies, while for blue galaxies the corresponding values are 0.98+0.08-0.07 and 0.84+0.20-0.16x10^13 h70^-1 Msun. For red lenses, the fraction which are satellites tends to decrease with luminosity and stellar mass, with the sample being nearly all satellites for a stellar mass of 2x10^9 h70^-2 Msun. The satellite fractions are generally close to zero for blue lenses, irrespective of luminosity or stellar mass. This, together with the shallower relation between halo mass and baryonic tracer, is a direct confirmation from galaxy-galaxy lensing that blue galaxies reside in less clustered environments than red galaxies. We also find that the halo model, while matching the lensing signal around red lenses well, is prone to over-predicting the large-scale signal for faint and less massive blue lenses. This could be a further indication that these galaxies tend to be more isolated than assumed. [abridged]