Host files are admittedly a bit techy.
A domain like boards.straightdope.com is meaningless to a computer. The computer has to convert the domain name to numbers that it can use. This is called domain name resolution. This starts by looking in your hosts file. The hosts file was mostly used back in the early days of computer networking. Most people don’t have anything useful in their hosts files these days. If no entry is found in the hosts file, the computer sends a DNS (domain name service) request to whatever computer is configured as that computer’s DNS server, which is typically a computer on the internet provider’s network (in other words, if Comcast provides your internet, the DNS server will be a computer on Comcast’s network). DNS is a hierarchy of computers. If the ISP’s computer doesn’t have an entry for the name, it sends the request further up the hierarchy. At the top there are 13 “root servers” for the entire internet. These computers have the master list of all domain names. If they don’t have an entry for it, then the request fails. There is nothing above those servers.
One way to kill off spam sites is to put an entry for them in your hosts file, and give it an IP of either 127.0.0.1 or 0.0.0.0. The IP address 127.0.0.1 is called the “loopback address” and always points to your own computer. 0.0.0.0 means that it’s an invalid IP address and can’t be resolved. If you use the loopback address, the request for the spam link goes to your own computer. Since your computer doesn’t have the file that the spam link is trying to load, the request fails and you don’t get the spam. If you use the 0.0.0.0 IP then the request immediately fails, and you don’t get the spam. Either way, you don’t get the spam.
Hosts files weren’t originally intended to be used to block things, but this works pretty effectively.
Sorry if that’s all a bit technical.
Hosts files were invented on unix machines, so on linux and all other unix derivatives, the hosts file is in \etc\hosts. Windows, despite being very much not unix based, kinda follows the unix convention, except they stick the file in their drivers directory. But it’s in windows\system32\drivers\etc\hosts.
Ad blockers and script blockers are typically add-ons to your browser and are much easier to install. I personally recommend using an ad blocker everywhere on the internet, not just for here. I also use a script blocker, but that requires a bit more fiddling on your part because blocking scripts universally tends to break a lot of web sites, so you have to know what you can allow to make the sites work without universally allowing scripts which brings in the bad with the good.
Moderators here can report problem ads, but otherwise we have absolutely no control over ads.