I want to block images in a website....so how could i do that using hosts file or any local way.
The Hosts file won't work for you. It blocks everything served by a server.
The HOSTS
file enables you to change the IP address your computer uses to connect to certain hosts. For example the following entry:
www.example.com 127.0.0.1
will cause your computer to direct all connections targeting the Internet host www.example.com
to 127.0.0.1.
However, what you're trying to do is block requests for resources on the Internet host, such as www.example.com/ads/somead.jpg, without blocking other content on the host. This cannot be done with the Hosts file; it's all or nothing.
I can't use any extensions
Bummer.
It's no good that the solution to your problem is to use browser extensions like AdBlock Plus. That's really the best approach when trying to implement something on your local machine to block unwanted ads.
If you happen to have control of the router that serves your network, it may have some options for blocking unwanted content at the network level.