Quick help when you can't remember

Cheat sheet 📌

The most useful bits of code in one place. You don't need to memorize them – even real programmers keep peeking at cheat sheets! You can print it out and keep it next to your keyboard.

Not sure what a word means? → Glossary

🧱 HTML – the page skeleton

HTML tells the browser WHAT is on the page. Tags usually open <like-this> and close </like-this>.

<h1>My website</h1>

The biggest heading. Only once per page – like a book's title.

<h2>Chapter</h2>

A smaller heading. They go all the way to <h6> (smallest).

<p>Hi, this is text.</p>

A paragraph of regular text.

<strong>important</strong>

Makes text bold.

<em>interesting</em>

Italic (slanted) text.

<a href="https://example.com">Click</a>

A link. href holds the address it should lead to.

<img src="dog.jpg" alt="My dog">

An image. src = the image file, alt = a description in case it doesn't load.

<ul>
  <li>first</li>
  <li>second</li>
</ul>

A bulleted list. Each item is an <li>.

<ol>
  <li>step 1</li>
  <li>step 2</li>
</ol>

A numbered list – the browser adds the numbers itself.

<div class="card">...</div>

A box for grouping things that belong together. You make up the class name yourself.

<!-- note to myself -->

A comment. The browser ignores it – it's just for you.

🎨 CSS – how the page looks

CSS says HOW things look. You pick WHAT to style (a selector), then write HOW inside curly braces.

h1 {
  color: red;
}

Every <h1> heading will be red.

.card {
  background: yellow;
}

Anything with class="card" gets a yellow background. A dot means "look for this class".

p {
  font-size: 20px;
}

The font size of paragraphs. Bigger number = bigger text.

body {
  font-family: Arial;
}

The font for the whole page.

.card {
  padding: 16px;
}

Inner spacing – padding between the content and the box's edge.

.card {
  margin: 16px;
}

Outer spacing – distance from the things around it.

.card {
  border: 2px solid black;
}

A border: thickness, line style and color.

.card {
  border-radius: 12px;
}

Rounded corners. Bigger number = rounder.

.menu {
  display: flex;
  gap: 10px;
}

Things inside line up side by side with a 10px gap. The magic trick for menus!

img {
  width: 200px;
}

The image's width. The height scales itself so it doesn't get squashed.

🪄 JavaScript – page behavior

JavaScript says what should HAPPEN – like after a click. It goes inside a <script> tag near the end of the page.

const name = 'Kate';

A variable – a labeled box you store something in.

let points = 0;
points = points + 1;

let is a box you can change. Here we're adding a point.

alert('Hi!');

Pops up a message box. Good for your first experiments.

console.log('it works');

Prints a message to the console (F12) – a secret window for programmers.

document.querySelector('h1')

Finds the first <h1> on the page so you can work with it.

element.textContent = 'New text';

Swaps the text inside the element you found.

element.addEventListener('click', () => {
  alert('Clicked!');
});

When someone clicks the element, whatever's inside runs.

if (points > 10) {
  alert('You won!');
}

A condition: the code inside only runs if what's in the parentheses is true.

element.classList.toggle("dark");

Adds a class if it's missing – and removes it if it's there. That's exactly how dark mode works.

🤖 Fetch & APIs – for Inventors

Fetch downloads data from the internet (weather, maps, AI). Answers come back as JSON – it looks like a JavaScript object.

const r = await fetch(address);

Send a request to an API and wait (await) for the answer.

const data = await r.json();

Turn the response into an object you can work with.

data.current_weather.temperature

Pull a value out of the object with dots – just like any other object.

await fetch('/ask', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({ question }),
});

POST = send data TO the server. body holds the object turned into text.

{ "city": "Prague", "temperature": 21 }

JSON – the shared language of APIs. Text in quotes, numbers without.

JSON.stringify(obj)

Turn an object into JSON text (before sending it).

JSON.parse(text)

Turn JSON text back into an object (after receiving it).

process.env.AI_KEY

On the server: read a secret key from the .env file. Keys never belong in the browser!

⌨️ Terminal & Git – for Masters and Data pros

The terminal is a window where you type text commands to the computer. Git remembers the history of your code.

cd my-website

Move into the my-website folder (cd = change directory).

ls

List what's in the current folder (on Windows: dir).

node server.js

Run the server.js file using Node.js.

npm install

Download all the packages the project needs.

git status

Show what changed in the project since the last save.

git add .

Stage all changes to be saved (the dot means "everything").

git commit -m "Added a menu"

Save the changes to history with a note about what you did.

git push

Send the saved changes to GitHub.

💡
How to use this cheat sheet: If you run into a tag or command in a lesson and don't know what it does – look it up here. If you don't know what a word means, check the Glossary.