# Build a Banking App Part 1: HTML Templates and Routes in a Web App Modern web applications have revolutionized how we interact with digital services, from social media platforms to online banking systems. Unlike traditional websites that reload entire pages for each interaction, today's web apps provide seamless, app-like experiences that respond instantly to user actions. This smooth interaction is powered by sophisticated techniques that update only specific parts of the page, creating the fluid experience users expect. | Traditional Multi-Page Apps | Modern Single-Page Apps | |----------------------------|-------------------------| | **Navigation** | Full page reload for each screen | Instant content switching | | **Performance** | Slower due to complete HTML downloads | Faster with partial updates | | **User Experience** | Jarring page flashes | Smooth, app-like transitions | | **Data Sharing** | Difficult between pages | Easy state management | | **Development** | Multiple HTML files to maintain | Single HTML with dynamic templates | **Understanding the evolution:** - **Traditional apps** require server requests for every navigation action - **Modern SPAs** load once and update content dynamically using JavaScript - **User expectations** now favor instant, seamless interactions - **Performance benefits** include reduced bandwidth and faster responses In this lesson, you'll discover how to build the foundation of a single-page application (SPA) by creating a banking app with multiple screens that never require a full page reload. You'll learn how HTML templates work as reusable building blocks, how JavaScript routing enables navigation between different views, and how the browser's history API creates a natural browsing experience. These concepts form the backbone of modern web development and are used by popular frameworks like React, Vue, and Angular. By the end of this lesson, you'll have built a functional multi-screen banking application that demonstrates professional web development techniques. You'll understand how to create smooth user experiences that rival native mobile apps, setting the foundation for more advanced web development skills. Let's start building something amazing! ## Pre-Lecture Quiz [Pre-lecture quiz](https://ff-quizzes.netlify.app/web/quiz/41) ### Prerequisite You need a local web server to test the web app we'll build in this lesson. If you don't have one, you can install [Node.js](https://nodejs.org) and use the command `npx lite-server` from your project folder. It will create a local web server and open your app in a browser. ### Preparation On your computer, create a folder named `bank` with a file named `index.html` inside it. We'll start from this HTML [boilerplate](https://en.wikipedia.org/wiki/Boilerplate_code): ```html Bank App ``` **Here's what this boilerplate provides:** - **Establishes** the HTML5 document structure with proper DOCTYPE declaration - **Configures** character encoding as UTF-8 for international text support - **Enables** responsive design with the viewport meta tag for mobile compatibility - **Sets** a descriptive title that appears in the browser tab - **Creates** a clean body section where we'll build our application > πŸ“ **Project Structure Preview** > > **By the end of this lesson, your project will contain:** > ``` > bank/ > β”œβ”€β”€ index.html > β”œβ”€β”€ app.js > └── style.css > ``` > > **File responsibilities:** > - **index.html**: Contains all templates and provides the app structure > - **app.js**: Handles routing, navigation, and template management > - **Templates**: Define the UI for login, dashboard, and other screens --- ## HTML Templates HTML templates are one of the most powerful features for building dynamic web applications. Instead of creating separate HTML files for each screen in your app, templates allow you to define reusable HTML structures that can be dynamically loaded and displayed as needed. This approach significantly improves performance and provides a smoother user experience. Think of templates as blueprints for different parts of your application. Just like an architect uses blueprints to construct different rooms in a building, you'll use HTML templates to construct different screens in your web app. The browser doesn't display these templates initially – they remain hidden until your JavaScript code activates them. If you want to create multiple screens for a web page, one solution would be to create one HTML file for every screen you want to display. However, this solution comes with some inconvenience: - You have to reload the entire HTML when switching screen, which can be slow. - It's difficult to share data between the different screens. Another approach is to have only one HTML file, and define multiple [HTML templates](https://developer.mozilla.org/docs/Web/HTML/Element/template) using the `