On every non-root switch, exactly one port is the root port. This is the port that provides the best path toward the root bridge. To select it, the switch compares the root path cost on each port. The port with the lowest cost wins. If costs tie, the switch compares the Bridge ID of the neighbor sending the BPDU. If that ties too, it uses the port ID. The root port forwards traffic toward the root. If your root port fails, STP recalculates and picks a new one.
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
$ curl repovive.com/roadmaps/network-design/spanning-tree-and-link-aggregation/root-port-selection
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░██████████████████████████████████████████████████████████████████████████████████████████████████