Bold, italic and line breaks in HTML & CSS
Topic 3 of 58 · 7 minFree lessonInside 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.
<p>Please <strong>do not</strong> feed the ducks.</p>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.
<p>I said the <em>blue</em> door, not the red one.</p>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.
<p> This is <strong>really <em>very</em> important</strong>.</p>New lines with br
The <br> element starts a new line inside the same paragraph. It's handy for poems and addresses.
<p> Roses are red,<br > Violets are blue.</p><br> has no closing tag, because it has nothing inside it. An element like this is called an empty element.
<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.<p>First paragraph.</p><br ><br ><p>Second paragraph.</p><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.