How to learn to code from scratch: a 2026 guide
To learn to code from scratch, pick one goal and one technology, practise a little every day and write code yourself instead of watching more courses. HTML and CSS are the easiest start, because you see results in the browser on day one. Then move on to JavaScript or Python.
You don't need a gift for maths or expensive hardware. A plan, consistency and some patience with your mistakes are enough. This guide covers the first weeks: choosing a technology, setting up your computer, a weekly plan, exercises, common traps and tracking progress.
Where to start: one goal and one technology
The most common mistake at the start is learning everything at once: some Python, some JavaScript, a video on artificial intelligence and another on mobile apps. A month later, what's left is mostly chaos. Focus on one goal and one technology, and leave the rest for later.
Set a concrete goal
"I want to be able to code" isn't enough, because you can't tell when you've got there. Goals you can see work better: "by the summer holidays I'll publish my own personal page" or "I'll write a script that sorts my photos into folders". A goal like that shows what to learn and what can wait.
Choose your first technology deliberately
Your first language won't decide your career. The point is to learn to think like a programmer: break a problem into small steps, check the result and fix what doesn't work. Three options work well for a start. HTML and CSS formally aren't programming languages but a markup language and a style sheet language, yet they give the quickest visible result.
| Technology | First result | Good for | Watch out for | Choose it if |
|---|---|---|---|---|
| HTML and CSS | Your own page in the browser | Websites, interfaces, a base for JavaScript | No program logic on their own | You want quick results |
| JavaScript | A button that reacts to a click | Interactive pages, web apps, servers | Hard to follow without HTML and CSS | The web and frontend interest you |
| Python | Text printed in the terminal | Automation, data analysis, machine learning | Less visual results, installing an interpreter | You prefer data, scripts and logic |
If you dream of your own website or of working on interfaces, start with frontend basics, for example the HTML and CSS course, then move on to JavaScript. If logic, data and automation appeal to you more, choose Python. For a broader comparison of paths, see where to start learning to code.
Set up your workspace in one afternoon
You don't need a powerful computer. Any machine that runs a modern browser and a code editor will do:
- A browser with developer tools. Chrome, Firefox and Edge have a built-in view of the page's code and a console that shows errors. Open them with F12 or Ctrl+Shift+I (Cmd+Option+I on a Mac), as the Chrome DevTools documentation describes.
- A code editor. The most popular free choice is Visual Studio Code, and the official getting started guide covers the basics. Add an extension that refreshes the preview on save, for example Live Server.
- One folder for learning, with a subfolder for every week or project.
- Git, a little later. This version control system records the history of your changes and lets you publish projects. Bring it in with your first project. The Pro Git book is free online.
MDN's guide Installing basic software has setup instructions for each system. Save your first file as index.html and open it in the browser:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>My first page</title>
</head>
<body>
<h1>Hi, I'm learning to code</h1>
<p>This is my first page.</p>
</body>
</html>When you get to Git, JavaScript outside the browser or Python, check in the terminal that everything is installed. Each command should print a version number, and on Windows Python usually answers to python --version or py --version:
git --version
node --version
python3 --versionA plan for your first weeks
Short daily practice works best. Half an hour every day gives more than six hours once a week, because you return to a topic before you forget it, and learning becomes an ordinary part of the day.
The weekly rhythm
- Monday to Friday, 30-45 minutes: a new portion of theory and, right away, a small example you write yourself.
- Saturday, 1-2 hours: a mini-project that combines what you learned during the week.
- Sunday, briefly: review, fixing bugs in your own code and planning the next week.
A sample plan for the web path
Treat this plan as a map, not a timetable. If one topic takes you two weeks, that's completely normal.
| Week | Topic | End-of-week exercise |
|---|---|---|
| 1 | HTML structure, headings, paragraphs, links, images | A page about yourself in plain HTML |
| 2 | Lists, tables, forms, semantic tags | A recipe or daily plan page |
| 3 | CSS basics: selectors, colours, fonts, the box model | The first week's page, styled |
| 4 | Flexbox and phone layouts | A personal page that works on a small screen |
| 5 | Git and publishing a page online | Your personal page at a public address |
| 6 | JavaScript: variables, conditions, loops | Logic tasks in the browser console |
| 7 | Functions and handling clicks | A click counter or theme switcher |
| 8 | Review and a project from an empty file | A shopping list you can add items to |
HTML and CSS basics covers the first four weeks in detail, and JavaScript for beginners expands on weeks six to eight.
On the Python path, swap the first five weeks for variables, data types, conditions, loops, functions and files, then finish with a script for a small everyday problem. The rhythm stays the same.
Learn by doing: starter exercises
Reading about programming isn't programming yet. With every course example, use a simple four-step method: retype it instead of copying, change one thing, break it on purpose and fix it. That way you learn the syntax and how to read errors at once. Exercises to begin with, from the simplest:
- A personal page: your name, a short bio, a list of interests and an email link. Plain HTML first, then colours and layout in CSS.
- A table of favourite films or books: HTML tables and colouring every other row in CSS.
- A click counter: a button that increases a number on the page with every click.
- A shopping list: a text field and a button that adds an item, and later a way to remove items.
- A guessing game in Python: the program picks a random number and you guess it, with "higher" or "lower" hints.
The click counter shows how little code a page needs to start reacting to the user. Add a <button id="counter"> and a <p id="result"> to your personal page, then this script:
const button = document.querySelector('#counter')
const result = document.querySelector('#result')
let clicks = 0
button.addEventListener('click', () => {
clicks = clicks + 1
result.textContent = `Clicked ${clicks} times`
})Save the Python guessing game as guess.py and run it with python3 guess.py:
import random
secret = random.randint(1, 100)
guess = None
while guess != secret:
guess = int(input("Enter a number from 1 to 100: "))
if guess < secret:
print("Higher")
elif guess > secret:
print("Lower")
print("Well done, that's the number!")Once it works, extend it: count the attempts, limit them to ten, ask about another round. Each change is a new small exercise.
How to practise so it sticks
Going through a lesson gives an illusion of understanding. Knowledge stays only when you pull it out of memory. Simple habits help:
- Write from memory. After a lesson, close the material and write the example again. What you can't recall shows what to review.
- Return to old exercises. A few days later, rebuild the personal page or the counter from an empty file.
- Explain it out loud, to someone or even a rubber duck, line by line. Where you get stuck, there's a gap.
- Keep a learning log: three sentences a day on what you did, what failed and what's next. After a month it shows progress you miss day to day.
Read error messages
An error message is a clue, not a verdict. It usually tells you three things: the type of error, what went wrong, and the file and line. Here's a typical one from the click counter:
Uncaught TypeError: Cannot read properties of null (reading 'addEventListener')
at script.js:5:8In plain words: on line five of script.js you're adding click handling to something that is null, meaning it doesn't exist. The usual culprit is a typo in the button's id or a script that runs before the browser has loaded the HTML. MDN's guide What went wrong? Troubleshooting JavaScript covers more cases like this.
When you get stuck
Set a limit for searching on your own, for example half an hour. Read the error, paste it into a search engine, and if that fails, ask people. A good question states your goal, what you've checked and the smallest piece of code that shows the problem. Stack Overflow explains this in its guides on how to ask a good question and how to create a minimal example. Often just writing the question down suggests the answer.
The mindset that gets you through hard weeks
Programming is mostly solving problems, not memorising syntax. Three principles help when nothing works:
- Errors are normal. Experienced developers see red messages every day too. The difference is that they can read them.
- You don't have to know everything. In the 2025 Stack Overflow Developer Survey, technical documentation was the most used learning resource: 67.8% of those answering the question had used it in the past year. Searching well matters more than memory, and MDN's free Learn web development materials are the easiest way to get used to reading documentation.
- Consistency beats intensity. A short daily session builds a habit, while a monthly burst mostly builds fatigue.
Common traps and how to avoid them
- Tutorial hell. You watch course after course and everything seems clear, but facing an empty file you don't know where to begin. After every lesson, build something small yourself, without peeking.
- Skipping the basics. Without understanding variables, conditions and loops, every framework looks like a set of magic spells.
- Hopping between technologies. A new language every week feels like progress but always ends at chapter one. Stick to one path until your first project is done.
- Comparing yourself with others. You don't know the story of someone who built an app in a weekend. Compare yourself with who you were a month ago.
- No projects. Projects, not certificates, best show that you can code.
- Handing all the work to AI. In the same survey question, 44% had learned with AI tools in the past year, so using them isn't the problem. Trouble starts when AI writes everything for you. At first, switch off automatic code suggestions, for example in GitHub Copilot or the Cursor editor, and ask AI to explain an error or give a hint, not a finished solution. App generators like Lovable build a prototype fast, but they won't teach you why the code works.
- Quitting at the first hard moment. Frustration is part of the process, not a sign this isn't for you. Take a break, come back tomorrow and split the problem into smaller pieces.
How to measure progress
Hours spent on a course say little. A far better measure is what you can do without anyone's help:
| Stage | How you know you're there | What you can show |
|---|---|---|
| First page | You write an HTML skeleton without peeking | An index.html file with your own content |
| Styling | You lay out elements with flexbox and know why they landed there | A personal page that works on a phone |
| Logic | You write a condition and a loop with no example beside you | A click counter or guessing game |
| Independence | You read an error and know where to look for the cause | A log entry with a solved problem |
| First project | You build a small app from an empty file | A page at a public address |
Add two simple tests. The empty file test: can you rebuild last week's project without opening the old code? The explanation test: can you explain to a friend what each part does? If not, repeat that stage. It's a normal learning pace, not a failure.
Check your HTML with the W3C validator, which flags unclosed tags and other errors. Publish finished projects, for example with GitHub Pages. A working page at a public address is the best proof of progress and the start of a portfolio.
Practising with CodeWorlds
If you'd rather follow a ready-made exercise path, you can practise on CodeWorlds. The first step is the HTML and CSS course in the Ancient Egypt world: 9 modules and 429 exercises on HTML5, CSS3, Flexbox, SASS and Grid, with the course page estimating 40-60 hours of learning. Basic computer skills and a browser are enough, since you solve the exercises in it and see at once if your code works.
For a good start, open the lessons Introduction to HTML, How the internet works and Introduction to CSS, and along the way do the business card mini-project, which matches the exercise from this article. The free plan covers this course in the app and gives you 10 fuel units a day to spend on exercises, which suits short daily sessions. After HTML and CSS, the course list includes JavaScript in Jurassic Park and Python in the Safari world, among others.
What next after the first weeks
Once your personal page is live and the click counter works, pick a direction. On the frontend path, deepen JavaScript until manipulating the page and fetching data stop surprising you. Only then reach for the React library, and later TypeScript, which adds types to JavaScript. Once you've mastered plain CSS, Tailwind CSS can speed up styling.
On the Python path, a good next step is the official Python tutorial. It assumes programming basics, so read it after your first weeks of exercises, not instead of them. The free freeCodeCamp curriculum has more projects to build yourself.
FAQ
Do you need to be good at maths to code?
No. For most of a developer's daily work, logical thinking and school maths are enough. Advanced maths helps in narrow fields such as 3D graphics or machine learning, which come much later.
Which programming language should I pick first?
If you want quick results, start with HTML and CSS, then move on to JavaScript. If data and automation interest you more, choose Python. What matters more than the choice is sticking with it until your first project is done.
Can I learn to code for free?
Yes. The MDN documentation, the official Python tutorial, freeCodeCamp and the Pro Git book are free. The CodeWorlds free plan covers the HTML and CSS course in the app with 10 fuel units a day for solving exercises, and you can read the lessons of every course for free on the site, so you can find out whether you enjoy programming without paying anything.
How long does it take to learn to code from scratch?
It depends on your goal, your weekly time and, above all, how much code you write yourself. The basics, meaning variables, conditions, loops and functions, come fastest with daily practice. A first project from an empty file pulls your knowledge together, and a level good enough to job hunt comes from months of systematic work and several projects, not one course. How to become a developer covers that stage.
How much time per day do I need to study?
As much as you can sustain for many weeks. The plan in this article assumes 30-45 minutes on weekdays and a longer Saturday session, because that rhythm fits around work or school. Regularity gives more than the hours in a single session.
Is it worth starting at 30, 40 or older?
Yes. People of every age learn to code, and work experience and problem-solving skills often prove an advantage when changing careers. Knowing a field, such as accounting or logistics, also suggests genuinely useful first projects.
What should I do when I get stuck and nothing works?
Take a short break, then read the error message carefully and check the line it points to. Search for the error text online and break the problem into smaller pieces. If you're still stuck after your time limit, ask the community and include the smallest piece of code that shows the problem.