Lesson 2 • Markdown
Basic Formatting
By the end of this lesson you'll be able to make text bold, italic, and struck through, drop in inline code and syntax-highlighted code blocks, and shape a document with blockquotes and dividers — the everyday toolkit behind every README, GitHub comment, and docs page.
Ctrl+Shift+V). Throughout this lesson the source sits beside the rendered result so you can see exactly what each symbol does.What You'll Learn
- Make text bold, italic, and bold+italic with * and _
- Strike text through with ~~ and write inline code with backticks
- Create fenced code blocks that get syntax highlighting
- Quote and nest blockquotes with >
- Add horizontal rules (---) to divide a document
- Force hard line breaks with two trailing spaces or a backslash
#. Everything else, we'll build here.💡 Real-World Analogy
Think of Markdown markers like a highlighter set. You don't open a menu to change a font — you wrap the words you care about in a symbol, the way you'd run a highlighter over a sentence. One asterisk on each side is a thin highlight (italic); two is a bold one; two tildes draw a line through it. The key habit: a marker has to hug both ends of the text, like opening and closing a bracket. Forget the closing marker and the renderer just shows the symbol as plain text.
1. Bold, Italic & Bold+Italic
Wrap text in one asterisk or underscore for italic, two for bold, and three for both at once. The marker must touch the text on both sides — **bold**, never ** bold **.
Source → Rendered
MARKDOWN SOURCE
This is *italic* text. This is _also italic_. This is **bold** text. This is __also bold__. This is ***bold and italic***.
RENDERED RESULT
This is italic text.
This is also italic.
This is bold text.
This is also bold.
This is bold and italic.
Pro Tip
Prefer asterisks (*) over underscores (_). Underscores inside words — like my_file_name — can accidentally trigger italics in some renderers. Asterisks never do.
2. Strikethrough & Inline Code
Two tildes on each side (~~like this~~) draw a line through text — handy for "old price, new price". A single backtick on each side makes inline code: a monospace snippet that won't be treated as Markdown, so symbols inside it stay literal.
Source → Rendered
MARKDOWN SOURCE
Was ~~£40~~ now £25. Run `npm install` to begin. The `Array.map()` method loops. Inside code, **stars** stay literal: `a ** b` means a to the power b.
RENDERED RESULT
Was £40 now £25.
Run npm install to begin.
The Array.map() method loops.
Inside code, stars stay literal: a ** b means a to the power b.
Need a literal backtick inside inline code? Wrap with double backticks: `` use `code` here ``.
🎯 Your Turn: emphasis markers
Fill in the ___ blanks with the right Markdown markers, then check your output against the expected result.
// 🎯 YOUR TURN — you're writing Markdown for a product page.
// Replace each ___ with the right marker, then press "Run".
// (This editor prints your text; paste the result into a Markdown
// previewer like dillinger.io to SEE it render.)
console.log("=== Build these lines ===");
// 1) Make the word "Sale" BOLD
console.log("___Sale___ ends Friday!"); // 👉 wrap Sale in **double asterisks**
// 2) Make the word "limited" ITALIC
console.log("Stock is ___limited___."); // 👉 wrap limi
...3. Fenced Code Blocks (with highlighting)
For more than a word or two of code, use a fence: three backticks on a line of their own, then your code, then three backticks to close. Write the language name right after the opening fence — ```js — and the renderer colours the keywords, strings, and numbers for you. Skip the language and you still get a code box, just no colours.
Source → Rendered
MARKDOWN SOURCE
```js
function greet(name) {
return "Hello, " + name + "!";
}
```
```bash
npm install
npm run dev
```RENDERED RESULT
function greet(name) {return "Hello, " + name + "!";}
# shell commandsnpm install npm run devCommon language tags: js, python, html, css, bash, json, sql, ts. GitHub, GitLab, and most docs tools recognise dozens more.
4. Blockquotes (and nesting)
Start a line with > to make a blockquote — usually rendered as an indented bar, great for callouts, quotes, or "Note:" boxes. Add a second >> to nest a quote inside a quote. Keep the > on every line you want included.
Source → Rendered
MARKDOWN SOURCE
> Note: save before you run. > It only takes a second. > Outer quote >> Nested reply >>> Even deeper
RENDERED RESULT
Note: save before you run. It only takes a second.
Outer quoteNested replyEven deeper
5. Horizontal Rules & Line Breaks
Three or more --- (or *** or ___) on a line by themselves draw a horizontal rule — a full-width divider. Line breaks are sneakier: a single newline is usually ignored. To force a hard break within a paragraph, end the line with two spaces or a backslash (\); leave a fully blank line to start a new paragraph.
Source → Rendered
MARKDOWN SOURCE
Section one. --- Roses are red·· (two trailing spaces) Violets are blue. Same line\ (backslash) New line below.
RENDERED RESULT
Section one.
Roses are red
Violets are blue.
Same line
New line below.
The ·· above marks two invisible trailing spaces. Because trailing spaces are easy to miss in review, many people prefer the visible backslash for hard breaks.
🎯 Your Turn: fences, quotes & rules
Fill in the ___ blanks to finish a README snippet, then check it against the expected rendered result.
// 🎯 YOUR TURN — finish this README snippet.
// Replace each ___ then press "Run".
console.log("=== A fenced code block ===");
// 1) Open the fence AND name the language so it gets highlighted
console.log("___js"); // 👉 three backticks then js (\`\`\`js)
console.log("const x = 41 + 1;");
console.log("console.log(x);");
console.log("___"); // 👉 three backticks to CLOSE (\`\`\`)
console.log("");
console.log("=== A blockquote ===");
// 2) Turn this note int
...Common Errors (and the fix)
- Spaces inside the markers:
** bold **renders as literal asterisks, not bold. The marker must hug the text — write**bold**with no inner spaces. - Forgetting the language on a code fence:
```alone still makes a code box but gives you no syntax highlighting. Add the tag:```js. - Unmatched
*markers: emphasis needs a matched pair.*italicwith no closing*shows a stray asterisk — every opening marker needs a closing one. - Unclosed code fence: forgetting the final
```swallows the rest of your document into the code box. Always close what you open. - Expecting a single newline to break a line: Markdown joins adjacent lines into one paragraph. Use two trailing spaces, a
\, or a blank line.
📋 Quick Reference
| Element | Syntax | Renders as |
|---|---|---|
| Bold | **text** | text |
| Italic | *text* or _text_ | text |
| Bold + italic | ***text*** | text |
| Strikethrough | ~~text~~ | |
| Inline code | `code` | code |
| Code block | ```js … ``` | highlighted box |
| Blockquote | > text | indented bar |
| Horizontal rule | --- | divider line |
| Hard line break | two spaces / \ | new line |
Frequently Asked Questions
Q: Should I use * or _ for emphasis?
Either works, but asterisks are safer. Underscores inside a word (like my_var_name) can be misread as italic by some parsers; asterisks never have that problem. Pick one and stay consistent.
Q: My code fence isn't getting colours — why?
You probably left off the language tag. Write the name right after the opening backticks, e.g. ```python. Also check the fence is exactly three backticks on its own line, not indented.
Q: Is strikethrough standard Markdown?
~~text~~ isn't in the original spec, but it's part of GitHub Flavored Markdown (GFM), which GitHub, GitLab, Reddit, and most modern tools use — so in practice it works almost everywhere.
Q: Why did my two lines merge into one?
A single newline doesn't break a line in Markdown. End the first line with two spaces or a backslash for a hard break, or leave a blank line between them to make separate paragraphs.
Mini-Challenge: Release Note
No blanks this time — just a brief and a blank canvas (with an outline to keep you on track). Write the Markdown yourself, run it, then paste the output into a previewer and check it against the expected result in the comments.
🎯 Mini-Challenge: write a release note
Combine bold, italic, inline code, a code fence, a blockquote, and a horizontal rule.
// 🎯 MINI-CHALLENGE: write the body of a release note.
// No blanks this time — type the Markdown yourself with console.log(...).
//
// 1. A blockquote (>) warning: "Breaking change in v2.0"
// 2. One sentence with the word "removed" in BOLD (**)
// and the word "deprecated" in ITALIC (*)
// 3. An inline code mention of \`config.json\`
// 4. A fenced code block tagged "json" with: { "version": 2 }
// 5. A horizontal rule (---) to close the note
//
// ✅ Expected rendered result:
// A quote
...🎉 Lesson Complete
- ✅
*italic*,**bold**,***both***— markers must hug the text, no inner spaces - ✅
~~strikethrough~~and`inline code`for snippets that stay literal - ✅ Fenced code blocks with a language tag (
```js) get syntax highlighting - ✅
>makes a blockquote;>>nests one inside another - ✅
---draws a horizontal rule; two trailing spaces or\force a hard line break - ✅ Next lesson: Lists & Tables — organise information into ordered, unordered, and tabular layouts
Sign up for free to track which lessons you've completed and get learning reminders.