Scalar fields have played an important role in the development of the fundamental theories of physics as well as in other branches of physics such as gravitation and cosmology. For a long time these escaped detection until 2012 year when the Higgs boson was observed for the first time. Since then alternatives to the general theory of relativity like the Brans-Dicke theory, scalar-tensor theories of gravity and their higher derivative generalizations -collectively known as Horndeski theories -have acquired renewed interest. In the present review we discuss on several selected topics regarding these theories, mainly from the theoretical perspective but with due mention of the observational aspect. Among the topics covered in this review we pay special attention to the following: 1) the asymptotic dynamics of cosmological models based in the Brans-Dicke, scalar-tensor and Horndeski theories, 2) inflationary models, extended quintessence and the Galileons, with emphasis in causality and stability issues, 3) the chameleon and Vainshtein screening mechanisms that may allow the elusive scalar field to evade the tight observational constraints implied by the solar system experiments, 4) the conformal frames conundrum with a brief discussion on the disformal transformations and 5) the role of Weyl symmetry and scale invariance in the gravitation theories. The review is aimed at specialists as well as at non-specialists in the subject, including postgraduate students.