In a layer 2 switched network, each network segment has its own collision domain and all segments are in same broadcast domain. Every broadcast is seen by every device on the network. A layer 3 device (typically a router) is used to segment (divide) a bradcast domain to multiple broadcast domains.
By default, all
ports on a switch are in the same broadcast domain. A Virtual Local Area Network, Virtual LAN, or VLAN, can be used to segment (divide) a single broadcast domain to multiple broadcast domains in a layer 2 switched network.
VLANs are not restricted to any physical boundary in the switched network if the devices are interconnected using switches. A VLAN can span across multiple switches, or it can be limited within a switch. A VLAN similar to an IP subnet and you need a layer 3 device (typically a router) to enable communication between different VLANs.