In normal light switches, two terminals are either connected or disconnected. However, in a three-way light switch, electricians use two special pieces of wiring and equipment to create three terminals, wherein the top terminal connects to one of the two bottom terminals. Whereas a normal switch has two terminals then, a three-way light switch will have three terminals and two will be connected to each other. This is also known as multiway switching.
Power arrives at a ceiling light fixture with two wires, which is a standard arrangement setup. Power then goes from the fixture in the middle to each wall switch via 3 wires, which are black, white and red. For clarification purposes, your arriving black and white wires are called common wires and the three wires are travelers. The common black brings the power.
At the light, connect the common black to the black traveler that goes to switch A. At switch A, connect the black traveler to the common terminal (darker in color or marked common). Run the common neutral wire (white) to the light. At switch A, connect the red traveler to a traveler terminal. Connect the white traveler to a traveler terminal on switch A and mark the end black with tape or paint to show it's hot.
At the light, connect the red traveler to the red traveler that runs to switch B. At switch B, connect the red traveler to a traveler terminal. At the light, connect the black traveler to the light. At switch B, connect the black traveler to the common terminal. At the light, connect the white traveler from switch A to the white traveler from switch B. At switch B, connect the white traveler to a traveler terminal and mark it black.
That should be it. Do not twist the wires before putting in the wire nuts. Let the nuts twist them tight. Also, don’t use push-in connection. Put wires around the screws.