I know how the Spanning tree protocol works ,but where its works whether in trunk port Scenario or access port? If works in trunk port how STP behave,then also how its behave in access port.
Trunk port is Cisco terminology and Cisco is one of the few vendors implementing Per VLAN Spanning Tree + (PVST+) which is the equivalent to 802.1D but with one spanning tree instance per VLAN. There is also Rapid Per VLAN Spanning Tree + (RPVST+) which is the equivalent of 802.1w but per VLAN. The plus means that STP is running over 802.1Q trunks as opposed to ISL.
On an access port, only one VLAN is allowed, hence only one instance of spanning tree will be running on the port and the Bridge Protocol Data Units (BPDUs) will be sent untagged. Normally access ports will connect to end devices and the port would be configured as an edge port to bypass listening and learning state and to not generate any Topology Change Notification (TCN) on link up/down. You could run an access port between switches as well but that is generally a waste because you will want to have several VLANs between the switches. So far everything is the same but Cisco runs PVST+/RPVST+ and other vendors run STP/RSTP.
On a trunk port (Cisco terminology) several VLANs will generally be allowed to traverse the trunk. On Cisco devices, every VLAN will in its own instance and different VLANs can be forwarding on blocking on the same physical port. On other vendors there will only be one instance running, even though several VLANs are traversing the trunk. This means that all VLANs most follow the same topology. It's not possible to any form of load sharing/traffic engineering.
Cisco devices will allow a different number of instances depending on what platform it is. Some will allow 32 instances, some 64 and some 128 and so on.
There is also the option of running Multiple Spanning Treee (MST) which does not do per VLAN Spanning Tree. Instead it groups VLANs together into instances which is more effective.
The advantage of PVST+/RPVST+ is that you can send VLANs on different paths and do traffic engineering. Also a change in one VLAN will not affect the others. The drawback is that it's less scalable if you have a lot of VLANs.
The reverse is true for STP/RSTP, it scales better but it does not offer load sharing and changes sourcing from one VLAN can affect the others.