(Simplified Abstract) To accomplish breakthroughs in dynamic whole-body locomotion, legged robots have to be terrain aware. Terrain-Aware Locomotion (TAL) implies that the robot can perceive the terrain with its sensors, and can take decisions based on this information. This thesis presents TAL strategies both from a proprioceptive and an exteroceptive perspective. The strategies are implemented at the level of locomotion planning, control, and state estimation, and using optimization and learning techniques. The first part is on TAL strategies at the Whole-Body Control (WBC) level. We introduce a passive WBC (pWBC) framework that allows the robot to stabilize and walk over challenging terrain while taking into account the terrain geometry (inclination) and friction properties. The pWBC relies on rigid contact assumptions which makes it suitable only for stiff terrain. As a consequence, we introduce Soft Terrain Adaptation aNd Compliance Estimation (STANCE) which is a soft terrain adaptation algorithm that generalizes beyond rigid terrain. The second part of the thesis focuses on vision-based TAL strategies. We present Vision-Based Terrain-Aware Locomotion (ViTAL) which is an online planning strategy that selects the footholds based on the robot capabilities, and the robot pose that maximizes the chances of the robot succeeding in reaching these footholds. ViTAL relies on a set of robot skills that characterizes the capabilities of the robot and its legs. The skills include the robot's ability to assess the terrain's geometry, avoid leg collisions, and avoid reaching kinematic limits. Our strategies are based on optimization and learning methods and are validated on HyQ and HyQReal in simulation and experiment. We show that with the help of these strategies, we can push dynamic legged robots one step closer to being fully autonomous and terrain aware.