When I first started learning web development, I made a mistake that caused me more confusion than I care to admit: I kept mixing frontend and backend code. At the time, I didn’t even realize it was a problem. I would write HTML, CSS, and JavaScript in the same files where I handled database queries or server logic. It seemed convenient at first  everything was in one place  but it quickly became messy and hard to debug.

I remember one project where I was building a simple task manager. I had the form for adding tasks in HTML, some JavaScript to handle the button clicks, and right next to it, I was writing PHP code to insert the task into the database. At first, it worked, but as soon as I tried to add more features, the code became impossible to manage. I couldn’t tell whether a bug was caused by the frontend or the backend, and making small changes often broke other parts of the app. It was frustrating.

That’s when I realized I needed to separate concerns. I started keeping the frontend  everything the user interacts with  in its own files. HTML, CSS, and JavaScript handled only the display and interaction. The backend, on the other hand, handled data processing, database access, and business logic. Once I started this separation, things became much clearer. If a bug appeared, I could quickly figure out whether it was a frontend or backend issue. If I wanted to change the design, I could do it without touching the server code.