Spanning tree is a link layer network protocol invented by Radia Perlman, that ensures a loop-free topology for any bridged LAN. Thus, the basic function of STP is to prevent bridge loops and ensuing broadcast radiation. As the name suggests, it creates a spanning tree within a mesh network of connected layer-2 bridges (typically Ethernet switches), and disables those links that are not part of the spanning tree, leaving a single active path between any two network nodes.
The STP is a simple protocol, but what is the better way to remember it? Singing!
Below the video with the spanning tree song :)