CHAPTER 09 · HTML
Paragraphs, spaces and breaks: make text easy to read
The way you arrange lines in your editor is not always the way text appears in the browser. This chapter explains ordinary paragraphs, collapsed spaces, intentional line breaks, topic breaks and text whose spacing really should be preserved.
Download example files (ZIP)What you will learn
Use a paragraph for one connected piece of text. Predict normal whitespace handling without calling it deletion of the source. Choose p, br, hr or pre for the right reason. Keep headings and other large structures outside paragraphs. Avoid spacing a page with empty paragraphs or repeated breaks.
A paragraph groups a thought
<p>The study meeting starts at 3 pm in Room 6.</p>
<p>Bring the example you want to explain.</p>Source lines and displayed lines are different
<p>Read one
question before writing.</p>Complete example: normal text and preserved spacing
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Text Spacing Practice</title>
</head>
<body>
<h1>Follow the practice steps</h1>
<p>Read one
question before writing.</p>
<p>The browser chooses line wrapping from the available width.</p>
<pre>Read
Try
Check</pre>
</body>
</html>This preview shows the example in a browser. Save the complete code in local files to test links between pages and downloads. Same-page section links work here.
Use br for an intentional break within the same content
<p>Peer learning desk<br>Room 6<br>Second floor</p>Use hr for a change of topic
<p>The desk is open on Tuesday.</p>
<hr>
<p>For lost items, contact the reception desk instead.</p>- 1p: another connected thought
- 2br: meaningful break within content
- 3hr: a change of topic
- 4pre: preserve meaningful spacing
Use CSS later for decorative gaps and borders. Do not arrange a page with many empty paragraphs or repeated line breaks.
A second complete example: two kinds of information
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Peer Learning Desk Notice</title>
</head>
<body>
<h1>Peer learning desk</h1>
<p>Find us here:<br>Room 6<br>Second floor</p>
<hr>
<p>Lost-item enquiries belong at reception.</p>
</body>
</html>This preview shows the example in a browser. Save the complete code in local files to test links between pages and downloads. Same-page section links work here.
Empty paragraphs do not create a good layout
A preview of non-breaking spaces
, a character reference representing a non-breaking space. A character reference is a written way to represent a character in HTML. This space can be useful when a particular pair of words or symbols should stay together.
Problem and solution: a location becomes one long line
Common mistakes and useful tips
Expecting source line breaks to always become visible line breaks: normal text uses whitespace and wrapping rules. Saying spaces are deleted from the saved file: display handling does not rewrite the original source. Using br to separate unrelated thoughts: use paragraphs where appropriate. Placing hr inside p: keep it as a sibling between the surrounding paragraphs. Adding many empty elements for spacing: use meaningful structure and later CSS. Using pre for every paragraph: preserve spacing only where that spacing is part of the content. Assuming all screens wrap at the same word: available width and text settings vary.
Practice questions
What does p describe? Predict the ordinary visible text of <p>Try one\nsmall task.</p>, where the source has an actual newline instead of the written backslash-n.Which element would you use between lines of a short room address? Why should hr normally sit outside a paragraph? How does pre differ from normal paragraph text handling? Create a complete club notice with two paragraphs, a short multiline location and a thematic break before a different enquiry topic. Explain each choice.
Check your practice answers
A paragraph: one connected piece of text. It normally reads Try one small task. It may still wrap on a narrow display, but not because of that source newline alone. Br, where the line divisions are meaningful parts of the location text. P contains paragraph text and suitable text-level content; hr represents a thematic break outside that paragraph content. Pre normally preserves its spaces and source line breaks. Ordinary paragraph flow usually collapses runs of whitespace and wraps to fit the available width. Use p for separate thoughts, br for the location's line divisions and hr between topics. Keep the complete document structure and avoid empty elements used only to make gaps.
Interview questions
How do p and br differ?
What does hr mean?
Why do several typed spaces often appear as one?
Why avoid repeated br elements for page layout?
Quick revision
Use paragraphs to group connected writing. Source newlines, intentional breaks and visual wrapping are different. Br breaks a line within content; hr separates topics. Pre preserves meaningful whitespace. Do not place headings or hr inside p. Use CSS later for layout spacing rather than empty paragraphs or repeated breaks.