Yes it works, but you might experience a "Back" bug . . .
if you go to a site that is displaying ads that your hosts file is blocking, then go from one page to another. If you click the Back button to go to the previous page, you will have to click it a number of times equal to the number of ads that were blocked.
Basically a hosts file redirects your browser to your local machine if the offending ip or url tries to appear. this causes the added entries in your Back history.
Except for that annoyance, using a hosts file is handy and works well!