Using the LLM to code
Using LLM as a co-architect to write HTML, CSS & JS
Can it really code?
It will sometimes help, sometimes hurt. YOU are the coder. When prompted properly, it will:
- Write large blocks of html inserting your content
- Keep your CSS clean and organized
- Learn your CSS and be able to apply tags consistently across pages
- Keep your JS organized
It will also hurt, if you aren't careful, it will:
- Code lazy: you think it’s writing an image scroll with 20 images, but it stops at 5 and inserts: // insert the rest of your images here
- Make up new CSS instead of looking at your existing stylesheet
- Randomly rename IDs and class names without warning, so your JS breaks silently
- Forget accessibility: it doesn’t check for alt tags, ARIA labels, or semantic structure unless you explicitly demand it
- Auto-close tags wrong or skip nesting checks—giving you beautiful-looking garbage that collapses under pressure
So I'm saying that it does it really right and really wrong at the same time? Yes! It's not a coder, it's an assistant that needs supervision. Someone on Reddit asked, "I don't know how to code; which LLM will build me an app with just my telling it what it needs to do?" Answer: none; you cannot use the LLM to code if you don't already have some sense of how coding works.
What I learned the hard way (Best Practices)
On other pages, I use sample prompts to show how context works. That’s harder here. Following is a list of best practices. I don't think there's a real way to avoid profanity while coding, even with the LLM. I hope these tips minimize your frustration. If you have others, please contact me and share!
- Keep your code in its own project
- Keep gold standard pages in the project files and reference them constantly! (index.html, xml, java, swift, css & js, for example.) As you update these files while coding, and prove them, update your gold standard file.
- Never trust the LLM to create a new tag. Always double-check! You'll find it created a tag for your "gallery" pages with the label "gallery." You need the exact same setup for your prompts pages. Instead of finding the gallery tag, it creates a new tag (same tag, different name.) Ask: "Why are you creating a new tag? Check CSS. We have a gallery tag that should work. Confirm!"
- Never paste full blocks of LLM-generated code without testing each part. It *will* skip steps, close things wrong, or misalign logic.
- Repeat to LLM ad nauseum: Do not code lazy; if there are 50 images, there are 50 lines of code. *always look for //...insert the rest here...// *
- Keep a copy of every *working* version before testing a big new change. LLMs are great at destroying something that “looked good a second ago.”
- Keep reminding the LLM that you are using industry best practices.