Hi I would like to ask if I want to build a web program with my raspberry pi and this web program runs offline, is it possible? I put everything in localhost so the raspberry literally runs back the localhost without connecting to the Internet.
Yes, this is possible and commonplace. You can access the server via
localhost, obviously enough. You should not have to do anything special in terms of configuring the server.
If you do not want it to accept requests from outside, you can either use the webserver itself to restrict this, or a firewall. However, this is probably not a significant issue on a home LAN.