Display ads function through ad networks like Google AdSense, which connect advertisers with website owners. Advertisers create their ads and set targeting criteria, while the network places these ads on relevant sites. The cost is often based on CPM (cost per thousand impressions) or CPC (cost per click).