CodeStride
Your First Web Page

Bold, italic and line breaks in HTML & CSS

Topic 3 of 58 · 7 minFree lesson

Inside a paragraph, some words need to stand out. HTML has elements that mark words as important or stressed. There's also one for starting a new line without starting a new paragraph.

Important words

The <strong> element marks words as important. Browsers show them in bold.

Example 1
<p>Please <strong>do not</strong> feed the ducks.</p>
Result

Stressed words

The <em> element, short for emphasis, marks a word you'd stress when you say it out loud. Browsers show it in italics.

Example 2
<p>I said the <em>blue</em> door, not the red one.</p>
Result

Elements inside elements

You can put elements inside other elements. This is called nesting. Close the inner element first, like closing a small box before the big box around it.

Example 3
<p> This is <strong>really <em>very</em> important</strong>.</p>
Result

New lines with br

The <br> element starts a new line inside the same paragraph. It's handy for poems and addresses.

Example 4
<p> Roses are red,<br > Violets are blue.</p>
Result

<br> has no closing tag, because it has nothing inside it. An element like this is called an empty element.

Common mistakeUsing <br> to add space between paragraphs. Write each paragraph as its own <p> instead. The space between them is a matter of looks, which you'll set with CSS.
Example 5Don't do this
<p>First paragraph.</p><br ><br ><p>Second paragraph.</p>
Result
TipYou may also see <b> and <i>, which look the same as <strong> and <em>. Prefer <strong> and <em>: they say what the words mean, and screen readers can use that.

Try it yourself

Run the code in the editor and answer 8 practice questions on bold, italic and line breaks. It's free, you only need an account.