Sometimes one word in a sentence needs to stand out. Formatting tags change how a few words look, right in the middle of a sentence.
flag
What you'll learn
How to make words bold, italic, underlined or highlighted.
How to cross out words and make small print.
How to write text slightly below or above the line, like H₂O and x².
waving_handLet's mark up some words
Formatting tags wrap around a few words inside a sentence and change how they look: bolder, slanted, highlighted, crossed out, smaller, or lifted a little up or down.
Unlike headings and paragraphs, they don't start a new line.
edit_note
Think of marking up your notes with pens. You press harder to make a word bold, slant your writing, underline a word, run a yellow highlighter over a key phrase, cross out a mistake, or write a tiny note in the corner.
Formatting tags do the same things to words on a web page.
<b>Breaking:</b> new phones are on sale.
Read it in <i>Front Page Weekly</i>.
<u>Update</u>: every phone comes with a free case.
Our top pick is <mark>the blue model</mark>.
Price: <del>₱20,000</del> ₱15,000
Water is H<sub>2</sub>O, and a square is x<sup>2</sup>.
Each pair wraps around only the words it changes. The rest of the sentence stays normal, and nothing moves to a new line.
searchA closer look
They stay inside the line
Formatting tags change a few words without breaking the line, so you'll usually put them inside a <p> or a heading.
A paragraph with a bold word in it is still one paragraph.
Two at once
You can put one formatting tag inside another. <b><i>Big sale</i></b> is bold and italic.
Just like in Lesson 1, close the inner tag first: </i> comes before </b>.
Looks or meaning
<b> and <i> only change how words look. HTML also has <strong>, for words that are important, and <em>, for words you would say with stress.
Browsers show them bold and italic too, and screen readers may read them with more emphasis. Either pair works while you're learning.
constructionLet's build it
Let's write a sale announcement for Front Page Bytes. Each step shows the whole page, and the new lines are highlighted.
1Step 1: Bold and italic
Your code
<!DOCTYPE html><html lang="en"> <head> <title>Front Page Bytes</title> </head> <body> <h2>Phone Sale This Weekend</h2> <p><b>Breaking:</b> three new phones are now on sale. Read the full review in <i>Front Page Weekly</i>.</p> </body></html>
What you see
description(no title)
<b> makes Breaking: bold so it catches the eye, and <i> slants the magazine name Front Page Weekly.
Notice that the rest of the sentence stays normal.
2Step 2: Highlight and underline
Your code
<!DOCTYPE html><html lang="en"> <head> <title>Front Page Bytes</title> </head> <body> <h2>Phone Sale This Weekend</h2> <p><b>Breaking:</b> three new phones are now on sale. Read the full review in <i>Front Page Weekly</i>.</p> <p>Our top pick is <mark>the blue model</mark>. <u>Update</u>: every phone now comes with a free case.</p> </body></html>
What you see
description(no title)
<mark> works like a highlighter pen and puts a yellow background behind the words. <u> draws a line under Update.
3Step 3: Cross out an old price
Your code
<!DOCTYPE html><html lang="en"> <head> <title>Front Page Bytes</title> </head> <body> <h2>Phone Sale This Weekend</h2> <p><b>Breaking:</b> three new phones are now on sale. Read the full review in <i>Front Page Weekly</i>.</p> <p>Our top pick is <mark>the blue model</mark>. <u>Update</u>: every phone now comes with a free case.</p> <p>Price: <del>₱20,000</del> ₱15,000</p> </body></html>
What you see
description(no title)
<del> draws a line through the old price, so readers can see it was changed instead of the number just disappearing.
4Step 4: Below and above the line
Your code
<!DOCTYPE html><html lang="en"> <head> <title>Front Page Bytes</title> </head> <body> <h2>Phone Sale This Weekend</h2> <p><b>Breaking:</b> three new phones are now on sale. Read the full review in <i>Front Page Weekly</i>.</p> <p>Our top pick is <mark>the blue model</mark>. <u>Update</u>: every phone now comes with a free case.</p> <p>Price: <del>₱20,000</del> ₱15,000</p> <p>Keep it away from water (H<sub>2</sub>O). This is the 2<sup>nd</sup> sale this year.</p> </body></html>
What you see
description(no title)
<sub> drops the 2 in H₂O a little below the line, and <sup> lifts the "nd" in 2ⁿᵈ a little above it. Both also make the text smaller.
Wrap the characters that sit lower, like the 2 in H₂O.
Examples
Water in science class.
<p>H<sub>2</sub>O</p>
Carbon dioxide.
<p>CO<sub>2</sub></p>
<sup>Above the line
x<sup>2</sup>
How to use
Wrap the characters that sit higher, like the 2 in x².
Examples
A number squared in math.
<p>x<sup>2</sup></p>
A date like the 1st.
<p>October 1<sup>st</sup></p>
reportCommon mistakes
These are mistakes many beginners make. Each mini browser shows what really happens.
error
Forgetting the slash in a closing tag
The mistake
<!DOCTYPE html><html lang="en"> <head> <title>Front Page Bytes</title> </head> <body> <p><b>Breaking:<b> new phones are on sale.</p> <p>Read the full story tomorrow.</p> </body></html>
What you see
description(no title)
The second <b> has no slash, so the browser reads it as another opening tag. Nothing gets closed, and the bold spreads into the next paragraph too.
tips_and_updatesTip: A closing tag always has a slash: </b>. If bold or italic spreads too far, look for a missing slash.
On the web, underlined words usually mean "click me". Readers may try to click today's deals in the first line, but only the second line is a real link.
tips_and_updatesTip: Use <u> sparingly. To make a word stand out, <b> or <mark> is usually clearer.
error
Closing two tags in the wrong order
The mistake
<!DOCTYPE html><html lang="en"> <head> <title>Front Page Bytes</title> </head> <body> <p><b><i>Big sale today!</b></i> Prices start at ₱300.</p> </body></html>
What you see
description(no title)
This one looks fine, because the browser quietly fixes the order. It's still best to close the inner tag first: the code is easier to read, and other tools may not fix it the same way.
tips_and_updatesTip: Close the inner tag first: <b><i>Big sale today!</i></b>
quizTest your knowledge
Edit the code on the left. The mini browser updates as you type, and each goal gets a check mark when it's done.
auto_awesomeNo clicking needed. Each goal gets a check mark by itself once your code does it.